From f878db0b4d5dc2905dd814cfbe76707f5d962921 Mon Sep 17 00:00:00 2001 From: Nimrod Adam Date: Sun, 22 Dec 2024 12:51:22 +0100 Subject: [PATCH] Add docs for command completion (#410) --- docs/command_completion.md | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 docs/command_completion.md diff --git a/docs/command_completion.md b/docs/command_completion.md new file mode 100644 index 00000000..8b162c31 --- /dev/null +++ b/docs/command_completion.md @@ -0,0 +1,53 @@ +# Command Completion + +MVT utilizes the [Click](https://click.palletsprojects.com/en/stable/) library for creating its command line interface. + +Click provides tab completion support for Bash (version 4.4 and up), Zsh, and Fish. + +To enable it, you need to register a special function with your shell, which varies depending on the shell you are using. + +`You need to start a new shell in order for the changes to be loaded.` + +### For Bash + +```bash +# Get the completion scripts +curl --tlsv1.3 -O https://github.com/mvt-project/mvt/tree/main/src/mvt/shell_completion/.mvt-{ios,android}-complete.bash + +# Source the file in ~/.bashrc. +. .mvt-android-complete.bash && . .mvt-ios-complete.bash +``` + +### For Zsh + +```bash +# Get the completion scripts +curl --tlsv1.3 -O https://github.com/mvt-project/mvt/tree/main/src/mvt/shell_completion/.mvt-{ios,android}-complete.zsh + +# Source the file in ~/.zshrc. +. .mvt-android-complete.zsh && . .mvt-ios-complete.zsh +``` + +## Generate Scripts locally + +In case you prefer not to download the command completion scripts from the MVT Project, you can generate your own scripts locally. + +### For Bash + +```bash +echo "$(_MVT_IOS_COMPLETE=bash_source mvt-ios)" > ~/.mvt-ios-complete.bash && +echo "$(_MVT_ANDROID_COMPLETE=bash_source mvt-android)" > ~/.mvt-android-complete.bash +``` + +### For Zsh +```bash +echo "$(_MVT_IOS_COMPLETE=zsh_source mvt-ios)" > ~/.mvt-ios-complete.zsh && +echo "$(_MVT_ANDROID_COMPLETE=zsh_source mvt-android)" > ~/.mvt-android-complete.zsh +``` + +You will then need to source the files in your shell configuration file and restart it for the changes to be loaded. + + +For more information, visit the official [Click Docs](https://click.palletsprojects.com/en/stable/shell-completion/#enabling-completion). + +