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 method | argparse | click | clap (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 string | prefix --x in decorator | .long("x") | implicit from flag name |
.short["x"]() | prefix -x in name string | implicit or combined with long | .short('x') | StringP → second arg |
.flag() | action="store_true" | is_flag=True | action(ArgAction::SetTrue) | BoolP / BoolVarP |
.required() | required=True | .required(true) | MarkFlagRequired() 1 | |
.positional() | no prefix (positional by default) | @click.argument() | .index(N) 2 | cmd.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() | BooleanOptionalAction | flag_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=N | nargs=N | .num_args(N) | — |
.range[min,max]() | type + manual check | type=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) + manual | ShorthandDeprecated() 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) 9 | TraverseChildren 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 method | argparse | click | clap (Rust) | cobra / pflag (Go) |
|---|---|---|---|---|
add_argument(arg) | add_argument(…) | @click.option / @click.argument | Arg::new(…) via derive / builder | cmd.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 method | argparse | click | clap (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 arg | MarkFlagsRequiredTogether() 1 |
required_if(target, cond) | — | — | .required_if_eq("x","v") | MarkFlagRequired… 1 |
implies(trigger, implied) | — | — | .requires_if("v","x") 12 | — |
Parser Behaviour
| ArgMojo method | argparse | click | clap (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() | — | — 9 | FParseErrWhitelist 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 method | argparse | click | clap (Rust) | cobra / pflag (Go) |
|---|---|---|---|---|
usage(text) | usage="…" | — | .override_usage("…") | Use: "…" |
add_tip(tip) | epilog="…" | epilog="…" | .after_help("…") | Example: "…" |
header_color[name]() | — | style() 13 | Styles::styled() 14 | — |
argument_color[name]() | — | style() 13 | Styles::styled() 14 | — |
warn_color[name]() | — | style() 13 | Styles::styled() 14 | — |
error_color[name]() | — | style() 13 | Styles::styled() 14 | — |
Shell Completions
| ArgMojo method | argparse | click | clap (Rust) | cobra / pflag (Go) |
|---|---|---|---|---|
disable_default_completions() | — | — | — | DisableAutoGenTag field |
completions_name(name) | — | — | — | — |
completions_as_subcommand() | — | — | clap_complete subcommand pattern | default (subcommand) |
generate_completion(shell) | — | shell_complete | clap_complete::generate() | GenBashCompletion() etc. |
Auto-Dispatch
| ArgMojo method | argparse | click | clap (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 method | argparse | click | clap (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.
-
Cobra / pflag uses imperative
cmd.MarkFlag…()calls on the command, not builder-chaining on the flag definition. ↩ ↩2 ↩3 ↩4 ↩5 -
clap positional args are defined by
.index(1),.index(2), etc., or by omitting.long()/.short(). ↩ -
Cobra uses
cobra.ExactArgs(n),cobra.MinimumNArgs(n), etc. — a completely different approach. ↩ -
No built-in support; typically implemented with custom validation logic. ↩ ↩2 ↩3 ↩4
-
click supports
--flag/--no-flagviais_flag=True, flag_value=…or thesecondaryparameter. ↩ -
Cobra / pflag has no first-class negatable flag; users manually add a
--no-xflag. ↩ -
argparse has
parents=for sharing argument definitions, but not inheritable persistent flags in a subcommand tree. ↩ -
click’s closest equivalent is
is_eagercombined with a custom callback; there is no directconstequivalent for options. ↩ -
clap uses
.trailing_var_arg(true)on the command (not the argument) for remainder-like behaviour. Forparse_known_arguments, clap has no direct equivalent; useallow_external_subcommands. ↩ ↩2 -
Cobra uses
TraverseChildrenfor remainder-like behaviour. For partial parsing, Cobra’sFParseErrWhitelist{UnknownFlags: true}ignores unknown flags. ↩ ↩2 -
click has no built-in
MutuallyExclusiveOption; it is typically implemented via a customclsor callback. ↩ -
clap’s
.requires_if("val", "other_arg")means “if this arg has valueval, thenother_argis also required”, which is a superset of ArgMojo’simplies. ↩ -
click uses
click.style()andclick.echo()for coloured output, not per-section colour configuration. Colour is applied manually per string, not as a command-level setting. ↩ ↩2 ↩3 ↩4 -
clap uses
Styles::styled()withAnsiColorenum values for header, literal, placeholder, and error colours. Applied at theCommandlevel. ↩ ↩2 ↩3 ↩4 -
Cobra’s
Runis a struct field of typefunc(cmd *Command, args []string). Unlike ArgMojo, the handler receives both the command and positional args (not aParseResult). ↩ -
click’s test runner (
CliRunner.invoke()) captures stdout and returns aResultobject, rather than dispatching through the normal execution path. ↩