aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Ouellette <oue.paul18@gmail.com>2019-08-02 00:59:52 -0400
committerPaul Ouellette <oue.paul18@gmail.com>2019-08-02 00:59:52 -0400
commitcdda7a8b924fd73682183ee8b29215e703bbb52f (patch)
tree24dfc64f8ca02e912f8f82b286b77da2c4c0c7ed
parentf82f796ef6838336d87e5f544b4fd82fd3117194 (diff)
downloadluarocks-cdda7a8b924fd73682183ee8b29215e703bbb52f.tar.gz
luarocks-cdda7a8b924fd73682183ee8b29215e703bbb52f.tar.bz2
luarocks-cdda7a8b924fd73682183ee8b29215e703bbb52f.zip
Fix epilog not showing with `luarocks help`
Argparse will print the help when we call :parse(), so the epilog has to be set at that time. We also want to show an up to date config text when using `luarocks`, so update the epilog then.
-rw-r--r--src/luarocks/cmd.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua
index 26780eed..0bbb9715 100644
--- a/src/luarocks/cmd.lua
+++ b/src/luarocks/cmd.lua
@@ -338,10 +338,17 @@ local function get_config_text(cfg)
338end 338end
339 339
340local function get_parser(description, cmd_modules) 340local function get_parser(description, cmd_modules)
341 local epilog = [[
342Variables:
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
341 local basename = dir.base_name(program) 348 local basename = dir.base_name(program)
342 local parser = argparse( 349 local parser = argparse(
343 basename, "LuaRocks "..cfg.program_version..", the Lua package manager\n\n".. 350 basename, "LuaRocks "..cfg.program_version..", the Lua package manager\n\n"..
344 program.." - "..description) 351 program.." - "..description, epilog)
345 :help_max_width(80) 352 :help_max_width(80)
346 :add_help("--help") 353 :add_help("--help")
347 :add_help_command() 354 :add_help_command()
@@ -557,14 +564,15 @@ function cmd.run_command(description, commands, external_namespace, ...)
557 cfg.local_cache = dir.path(fs.system_cache_dir(), "luarocks") 564 cfg.local_cache = dir.path(fs.system_cache_dir(), "luarocks")
558 end 565 end
559 566
560 parser:epilog([[ 567 if not args.command then
568 -- Update the config text
569 parser:epilog([[
561Variables: 570Variables:
562 Variables from the "variables" table of the configuration file can be 571 Variables from the "variables" table of the configuration file can be
563 overridden with VAR=VALUE assignments. 572 overridden with VAR=VALUE assignments.
564 573
565]]..get_config_text(cfg)) 574]]..get_config_text(cfg))
566 575
567 if not args.command then
568 util.printout() 576 util.printout()
569 util.printout(parser:get_help()) 577 util.printout(parser:get_help())
570 util.printout() 578 util.printout()