From 0baf5c1481239144ff5ed1fcced2b78d221896a0 Mon Sep 17 00:00:00 2001 From: Lazarus Lazaridis Date: Thu, 8 Mar 2018 03:22:57 +0200 Subject: [PATCH] Provide version command Fixes #10 --- README.md | 11 +++++++++++ goto.bash | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9679e9c..d6e11b9 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,17 @@ or goto --help ``` +### Version + +To view the tool's version, use: +```bash +goto -v +``` +or +```bash +goto --version +``` + ## TODO * ~~Test on macOS~~ extensively diff --git a/goto.bash b/goto.bash index cacf379..72e55da 100644 --- a/goto.bash +++ b/goto.bash @@ -51,6 +51,9 @@ function goto() -h|--help) _goto_usage ;; + -v|--version) + _goto_version + ;; *) _goto_directory "$subcommand" ;; @@ -76,9 +79,17 @@ OPTIONS: goto -c|--cleanup -h, --help: prints this help goto -h|--help + -v, --version: displays the version of the goto script + goto -v|--version USAGE } +# Displays version +function _goto_version() +{ + echo "goto version 1.0.0" +} + # Expands directory. # Helpful for ~, ., .. paths function _goto_expand_directory() @@ -214,7 +225,7 @@ function _goto_resolve_alias() # Completes the goto function with the available commands function _complete_goto_commands() { - mapfile -t COMPREPLY < <(compgen -W '-r --register -u --unregister -l --list -c --cleanup' -- "$1") + mapfile -t COMPREPLY < <(compgen -W '-r --register -u --unregister -l --list -c --cleanup -v --version' -- "$1") } # Completes the goto function with the available aliases