Provide version command

Fixes #10
This commit is contained in:
Lazarus Lazaridis 2018-03-08 03:22:57 +02:00
parent dae1cbd612
commit 0baf5c1481
2 changed files with 23 additions and 1 deletions

View File

@ -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

View File

@ -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