Skip to content

Commit

Permalink
Allow user defined help string at CommandSpec.add_help() (ponylang#2535)
Browse files Browse the repository at this point in the history
* Allow user defined help string at CommandSpec.add_help()

* Rename hinfo to descr',and leave it empty
  • Loading branch information
Sleeplessy authored and dipinhora committed Jun 5, 2018
1 parent d1e622c commit 9ab5341
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/cli/command_spec.pony
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CommandSpec
let _descr: String
let _options: Map[String, OptionSpec] = _options.create()
var _help_name: String = ""
var _help_info: String = ""

// A parent commands can have sub-commands; leaf commands can have args.
let _commands: Map[String, CommandSpec box] = _commands.create()
Expand Down Expand Up @@ -79,12 +80,13 @@ class CommandSpec
if _args.size() > 0 then error end
_commands.update(cmd.name(), cmd)

fun ref add_help(hname: String = "help") ? =>
fun ref add_help(hname: String = "help", descr': String = "") ? =>
"""
Adds a standard help option and, optionally command, to a root command.
"""
_help_name = hname
let help_option = OptionSpec.bool(_help_name, "", 'h', false)
_help_info = descr'
let help_option = OptionSpec.bool(_help_name, _help_info, 'h', false)
_options.update(_help_name, help_option)
if _args.size() == 0 then
let help_cmd = CommandSpec.leaf(_help_name, "", Array[OptionSpec](), [
Expand Down

0 comments on commit 9ab5341

Please sign in to comment.