diff options
| author | Paul Ouellette <oue.paul18@gmail.com> | 2019-07-29 17:53:07 -0400 |
|---|---|---|
| committer | Paul Ouellette <oue.paul18@gmail.com> | 2019-08-01 23:53:03 -0400 |
| commit | b4d7742508105244053ebea15cac5cc570e4337f (patch) | |
| tree | 825d75cfea13ac231bc58e49165ee1ab5c0df277 | |
| parent | fe3885908acb53b1bb63803d029f704c76195b8b (diff) | |
| download | luarocks-b4d7742508105244053ebea15cac5cc570e4337f.tar.gz luarocks-b4d7742508105244053ebea15cac5cc570e4337f.tar.bz2 luarocks-b4d7742508105244053ebea15cac5cc570e4337f.zip | |
Add completion command
| -rw-r--r-- | src/luarocks/cmd.lua | 34 |
1 files changed, 33 insertions, 1 deletions
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: | |||
| 345 | 345 | ||
| 346 | ]]..get_config_text(cfg) | 346 | ]]..get_config_text(cfg) |
| 347 | 347 | ||
| 348 | local basename = dir.base_name(program) | ||
| 348 | local parser = argparse( | 349 | local parser = argparse( |
| 349 | dir.base_name(program), "LuaRocks "..cfg.program_version..", the Lua package manager\n\n".. | 350 | basename, "LuaRocks "..cfg.program_version..", the Lua package manager\n\n".. |
| 350 | program.." - "..description, epilog) | 351 | program.." - "..description, epilog) |
| 351 | :help_max_width(80) | 352 | :help_max_width(80) |
| 352 | :add_help("--help") | 353 | :add_help("--help") |
| 353 | :add_help_command() | 354 | :add_help_command() |
| 355 | :add_complete_command({ | ||
| 356 | help_max_width = 120, | ||
| 357 | summary = "Output a shell completion script.", | ||
| 358 | description = [[ | ||
| 359 | Output a shell completion script. | ||
| 360 | |||
| 361 | Enabling completions for Bash: | ||
| 362 | |||
| 363 | Add the following line to your ~/.bashrc: | ||
| 364 | source <(]]..basename..[[ completion bash) | ||
| 365 | or save the completion script to the local completion directory: | ||
| 366 | ]]..basename..[[ completion bash > ~/.local/share/bash-completion/completions/]]..basename..[[ | ||
| 367 | |||
| 368 | |||
| 369 | Enabling completions for Zsh: | ||
| 370 | |||
| 371 | Save the completion script to a file in your $fpath. | ||
| 372 | You can add a new directory to your $fpath by adding e.g. | ||
| 373 | fpath=(~/.zfunc $fpath) | ||
| 374 | to your ~/.zshrc. | ||
| 375 | Then run: | ||
| 376 | ]]..basename..[[ completion zsh > ~/.zfunc/_]]..basename..[[ | ||
| 377 | |||
| 378 | |||
| 379 | Enabling completion for Fish: | ||
| 380 | |||
| 381 | Add the following line to your ~/.config/fish/config.fish: | ||
| 382 | ]]..basename..[[ completion fish | source | ||
| 383 | or save the completion script to the local completion directory: | ||
| 384 | ]]..basename..[[ completion fish > ~/.config/fish/completions/]]..basename..[[.fish | ||
| 385 | ]]}) | ||
| 354 | :command_target("command") | 386 | :command_target("command") |
| 355 | :require_command(false) | 387 | :require_command(false) |
| 356 | 388 | ||
