Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Cross-Library Method Name Reference

The table below maps every ArgMojo builder method / command-level method to its equivalent in four popular CLI libraries. An empty cell means the name is identical (or near-identical) to ArgMojo’s. A filled cell shows the other library’s name or approach. — means the library has no built-in equivalent.

Libraries compared: argparse (Python stdlib), click (Python CLI framework), clap (Rust, derive & builder API), cobra / pflag (Go).

Argument-Level Builder Methods

ArgMojo methodargparseclickclap (Rust)cobra / pflag (Go)
Argument("name", help="…")add_argument("name", help="…")@click.option("--name", help="…")Arg::new("name").help("…")cmd.Flags().StringP(…)
.long["x"]()prefix --x in name stringprefix --x in decorator.long("x")implicit from flag name
.short["x"]()prefix -x in name stringimplicit or combined with long.short('x')StringP → second arg
.flag()action="store_true"is_flag=Trueaction(ArgAction::SetTrue)BoolP / BoolVarP
.required()required=True.required(true)MarkFlagRequired() 1
.positional()no prefix (positional by default)@click.argument().index(N) 2cmd.Args 3
.takes_value()(default for non-flag)(default for options).action(ArgAction::Set)(default for non-bool)
.default["val"]()default="val".default_value("val")flag definition arg
.choice["a"]().choice["b"]()choices=["a","b"]type=click.Choice(…).value_parser(["a","b"])— 4
.value_name["FILE"]()metavar="FILE"metavar="FILE".value_name("FILE")—
.hidden()help=argparse.SUPPRESS.hide(true)MarkHidden() 1
.count()action="count"count=True.action(ArgAction::Count)CountP / CountVarP
.max[N]()————
.negatable()BooleanOptionalActionflag_value / is_flag + secondary 5—--no-x pattern 6
.append()action="append"multiple=True.action(ArgAction::Append)StringSliceP
.delimiter[","]()type + split—.value_delimiter(',')StringSliceP (comma default)
.number_of_values[N]()nargs=Nnargs=N.num_args(N)—
.range[min,max]()type + manual checktype=IntRange(…).value_parser(RangedI64…)— 4
.clamp()—clamp=True (on IntRange)——
.map_option()————
.alias["alt"]()— (use multiple names)—.visible_alias("alt")—
.deprecated["msg"]()deprecated (3.13+)deprecated=True.hide(true) + manualShorthandDeprecated() 1
.persistent()— 7—.global(true)PersistentFlags()
.default_if_no_value["val"]()const="val" + nargs="?"— 8.default_missing_value("val")NoOptDefVal field
.require_equals()——.require_equals(true)—
.remainder()nargs=argparse.REMAINDER—.trailing_var_arg(true) 9TraverseChildren 10
.allow_hyphen_values()——.allow_hyphen_values(true)—
.prompt()—prompt=True——
.prompt["msg"]()—prompt="msg"——
.password()—hide_input=True——
.group["name"]()— (manual section formatting)—.help_heading("name")— (manual grouping)

Command-Level Methods

Registration & Structure

ArgMojo methodargparseclickclap (Rust)cobra / pflag (Go)
add_argument(arg)add_argument(…)@click.option / @click.argumentArg::new(…) via derive / buildercmd.Flags().…
add_subcommand(sub)add_subparsers().add_parser(…)@group.command() / .add_command().subcommand(Command::new(…))parent.AddCommand(child)
add_parent(parent)parents=[parent]———
command_aliases(names)— (use multiple names)—.visible_aliases([…])Aliases: []string{…}
hidden() (command)—hidden=True.hide(true)Hidden: true
disable_help_subcommand()——.disable_help_subcommand(true)—
allow_positional_with_subcommands()———TraverseChildren

Group Constraints

ArgMojo methodargparseclickclap (Rust)cobra / pflag (Go)
mutually_exclusive(…)add_mutually_exclusive_group()cls=MutuallyExclusiveOption 11.conflicts_with("x") per arg— 4
one_required(…)group + required=True—.group("G").required(true)— 4
required_together(…)——.requires("x") per argMarkFlagsRequiredTogether() 1
required_if(target, cond)——.required_if_eq("x","v")MarkFlagRequired… 1
implies(trigger, implied)——.requires_if("v","x") 12—

Parser Behaviour

ArgMojo methodargparseclickclap (Rust)cobra / pflag (Go)
help_on_no_arguments()—invoke_without_command=False.arg_required_else_help(true)auto (shows usage)
allow_negative_numbers()——.allow_negative_numbers(true)—
allow_negative_expressions()————
parse_known_arguments()parse_known_args()—— 9FParseErrWhitelist 10
response_file_prefix()fromfile_prefix_chars="@"———
response_file_max_depth[N]()————
confirmation_option()—confirmation_option——
disable_fullwidth_correction()————
disable_punctuation_correction()————

Help & Display

ArgMojo methodargparseclickclap (Rust)cobra / pflag (Go)
usage(text)usage="…"—.override_usage("…")Use: "…"
add_tip(tip)epilog="…"epilog="…".after_help("…")Example: "…"
header_color[name]()—style() 13Styles::styled() 14—
argument_color[name]()—style() 13Styles::styled() 14—
warn_color[name]()—style() 13Styles::styled() 14—
error_color[name]()—style() 13Styles::styled() 14—

Shell Completions

ArgMojo methodargparseclickclap (Rust)cobra / pflag (Go)
disable_default_completions()———DisableAutoGenTag field
completions_name(name)————
completions_as_subcommand()——clap_complete subcommand patterndefault (subcommand)
generate_completion(shell)—shell_completeclap_complete::generate()GenBashCompletion() etc.

Auto-Dispatch

ArgMojo methodargparseclickclap (Rust)cobra / pflag (Go)
set_run_function(handler)—callback param on @command—Run: func(…) 15
execute()—implicit via cli()—cmd.Execute()
_execute_with_arguments(args)—runner.invoke(cli, args) 16——

Parse

ArgMojo methodargparseclickclap (Rust)cobra / pflag (Go)
parse()parse_args()implicit.get_matches()implicit
parse_arguments(args)parse_args(args).main(args=…).get_matches_from(args)—

Notes (Cross-Library Method Name Reference)

See the footnotes at the bottom of this document.


  1. Cobra / pflag uses imperative cmd.MarkFlag…() calls on the command, not builder-chaining on the flag definition. ↩ ↩2 ↩3 ↩4 ↩5

  2. clap positional args are defined by .index(1), .index(2), etc., or by omitting .long() / .short(). ↩

  3. Cobra uses cobra.ExactArgs(n), cobra.MinimumNArgs(n), etc. — a completely different approach. ↩

  4. No built-in support; typically implemented with custom validation logic. ↩ ↩2 ↩3 ↩4

  5. click supports --flag/--no-flag via is_flag=True, flag_value=… or the secondary parameter. ↩

  6. Cobra / pflag has no first-class negatable flag; users manually add a --no-x flag. ↩

  7. argparse has parents= for sharing argument definitions, but not inheritable persistent flags in a subcommand tree. ↩

  8. click’s closest equivalent is is_eager combined with a custom callback; there is no direct const equivalent for options. ↩

  9. clap uses .trailing_var_arg(true) on the command (not the argument) for remainder-like behaviour. For parse_known_arguments, clap has no direct equivalent; use allow_external_subcommands. ↩ ↩2

  10. Cobra uses TraverseChildren for remainder-like behaviour. For partial parsing, Cobra’s FParseErrWhitelist{UnknownFlags: true} ignores unknown flags. ↩ ↩2

  11. click has no built-in MutuallyExclusiveOption; it is typically implemented via a custom cls or callback. ↩

  12. clap’s .requires_if("val", "other_arg") means “if this arg has value val, then other_arg is also required”, which is a superset of ArgMojo’s implies. ↩

  13. click uses click.style() and click.echo() for coloured output, not per-section colour configuration. Colour is applied manually per string, not as a command-level setting. ↩ ↩2 ↩3 ↩4

  14. clap uses Styles::styled() with AnsiColor enum values for header, literal, placeholder, and error colours. Applied at the Command level. ↩ ↩2 ↩3 ↩4

  15. Cobra’s Run is a struct field of type func(cmd *Command, args []string). Unlike ArgMojo, the handler receives both the command and positional args (not a ParseResult). ↩

  16. click’s test runner (CliRunner.invoke()) captures stdout and returns a Result object, rather than dispatching through the normal execution path. ↩