From b4d7742508105244053ebea15cac5cc570e4337f Mon Sep 17 00:00:00 2001 From: Paul Ouellette Date: Mon, 29 Jul 2019 17:53:07 -0400 Subject: Add completion command --- src/luarocks/cmd.lua | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 60aa633c..174da616 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua @@ -345,12 +345,44 @@ Variables: ]]..get_config_text(cfg) + local basename = dir.base_name(program) local parser = argparse( - dir.base_name(program), "LuaRocks "..cfg.program_version..", the Lua package manager\n\n".. + basename, "LuaRocks "..cfg.program_version..", the Lua package manager\n\n".. program.." - "..description, epilog) :help_max_width(80) :add_help("--help") :add_help_command() + :add_complete_command({ + help_max_width = 120, + summary = "Output a shell completion script.", + description = [[ +Output a shell completion script. + +Enabling completions for Bash: + + Add the following line to your ~/.bashrc: + source <(]]..basename..[[ completion bash) + or save the completion script to the local completion directory: + ]]..basename..[[ completion bash > ~/.local/share/bash-completion/completions/]]..basename..[[ + + +Enabling completions for Zsh: + + Save the completion script to a file in your $fpath. + You can add a new directory to your $fpath by adding e.g. + fpath=(~/.zfunc $fpath) + to your ~/.zshrc. + Then run: + ]]..basename..[[ completion zsh > ~/.zfunc/_]]..basename..[[ + + +Enabling completion for Fish: + + Add the following line to your ~/.config/fish/config.fish: + ]]..basename..[[ completion fish | source + or save the completion script to the local completion directory: + ]]..basename..[[ completion fish > ~/.config/fish/completions/]]..basename..[[.fish +]]}) :command_target("command") :require_command(false) -- cgit v1.2.3-55-g6feb