diff options
| author | Paul Ouellette <oue.paul18@gmail.com> | 2019-08-17 01:29:07 -0400 |
|---|---|---|
| committer | Paul Ouellette <oue.paul18@gmail.com> | 2019-08-17 01:29:07 -0400 |
| commit | 5f35b21824fa4ec4670e5b98020533bedc147a82 (patch) | |
| tree | 395c0653ddd78d9bc9fa01e5b27eedee909cd60e | |
| parent | 9fefe1dd0692e842693d6aea5c06396e0b25ee6f (diff) | |
| download | luarocks-5f35b21824fa4ec4670e5b98020533bedc147a82.tar.gz luarocks-5f35b21824fa4ec4670e5b98020533bedc147a82.tar.bz2 luarocks-5f35b21824fa4ec4670e5b98020533bedc147a82.zip | |
Show config text only when run with no arguments
| -rw-r--r-- | src/luarocks/cmd.lua | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 0cb4135a..f424f488 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
| @@ -304,6 +304,13 @@ do | |||
| 304 | end | 304 | end |
| 305 | end | 305 | end |
| 306 | 306 | ||
| 307 | local variables_help = [[ | ||
| 308 | Variables: | ||
| 309 | Variables from the "variables" table of the configuration file can be | ||
| 310 | overridden with VAR=VALUE assignments. | ||
| 311 | |||
| 312 | ]] | ||
| 313 | |||
| 307 | local function get_status(status) | 314 | local function get_status(status) |
| 308 | return status and "ok" or "not found" | 315 | return status and "ok" or "not found" |
| 309 | end | 316 | end |
| @@ -338,21 +345,15 @@ local function get_config_text(cfg) | |||
| 338 | end | 345 | end |
| 339 | 346 | ||
| 340 | local function get_parser(description, cmd_modules) | 347 | local function get_parser(description, cmd_modules) |
| 341 | local epilog = [[ | ||
| 342 | Variables: | ||
| 343 | Variables from the "variables" table of the configuration file can be | ||
| 344 | overridden with VAR=VALUE assignments. | ||
| 345 | |||
| 346 | ]]..get_config_text(cfg) | ||
| 347 | |||
| 348 | local basename = dir.base_name(program) | 348 | local basename = dir.base_name(program) |
| 349 | local parser = argparse( | 349 | local parser = argparse( |
| 350 | basename, "LuaRocks "..cfg.program_version..", the Lua package manager\n\n".. | 350 | basename, "LuaRocks "..cfg.program_version..", the Lua package manager\n\n".. |
| 351 | program.." - "..description, epilog) | 351 | program.." - "..description, variables_help.."Run '"..basename.. |
| 352 | "' without any arguments to see the configuration.") | ||
| 352 | :help_max_width(80) | 353 | :help_max_width(80) |
| 353 | :add_help_command() | 354 | :add_help_command() |
| 354 | :add_complete_command({ | 355 | :add_complete_command({ |
| 355 | help_max_width = 120, | 356 | help_max_width = 100, |
| 356 | summary = "Output a shell completion script.", | 357 | summary = "Output a shell completion script.", |
| 357 | description = [[ | 358 | description = [[ |
| 358 | Output a shell completion script. | 359 | Output a shell completion script. |
| @@ -564,14 +565,7 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
| 564 | end | 565 | end |
| 565 | 566 | ||
| 566 | if not args.command then | 567 | if not args.command then |
| 567 | -- Update the config text | 568 | parser:epilog(variables_help..get_config_text(cfg)) |
| 568 | parser:epilog([[ | ||
| 569 | Variables: | ||
| 570 | Variables from the "variables" table of the configuration file can be | ||
| 571 | overridden with VAR=VALUE assignments. | ||
| 572 | |||
| 573 | ]]..get_config_text(cfg)) | ||
| 574 | |||
| 575 | util.printout() | 569 | util.printout() |
| 576 | util.printout(parser:get_help()) | 570 | util.printout(parser:get_help()) |
| 577 | util.printout() | 571 | util.printout() |
