Skip to content

Commit 23c5bc7

Browse files
authored
cli: add missing struct members to str() method and fix some comments (#23893)
1 parent b1d6b78 commit 23c5bc7

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

vlib/cli/command.v

+32-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,34 @@ pub fn (cmd &Command) str() string {
8383
res << ' flags: ${cmd.flags}'
8484
res << ' required_args: ${cmd.required_args}'
8585
res << ' args: ${cmd.args}'
86+
res << ' posix_mode: ${cmd.posix_mode}'
87+
match cmd.defaults.help {
88+
bool {
89+
res << ' defaults.help: ${cmd.defaults.help}'
90+
}
91+
CommandFlag {
92+
res << ' defaults.help.command: ${cmd.defaults.help.command}'
93+
res << ' defaults.help.flag: ${cmd.defaults.help.flag}'
94+
}
95+
}
96+
match cmd.defaults.man {
97+
bool {
98+
res << ' defaults.man: ${cmd.defaults.man}'
99+
}
100+
CommandFlag {
101+
res << ' defaults.man.command: ${cmd.defaults.man.command}'
102+
res << ' defaults.man.flag: ${cmd.defaults.man.flag}'
103+
}
104+
}
105+
match cmd.defaults.version {
106+
bool {
107+
res << ' defaults.version: ${cmd.defaults.version}'
108+
}
109+
CommandFlag {
110+
res << ' defaults.version.command: ${cmd.defaults.version.command}'
111+
res << ' defaults.version.flag: ${cmd.defaults.version.flag}'
112+
}
113+
}
86114
res << '}'
87115
return res.join('\n')
88116
}
@@ -217,7 +245,7 @@ pub fn (mut cmd Command) parse(args []string) {
217245
cmd.parse_commands()
218246
}
219247

220-
// add_default_flags adds the commonly used `-h`/`--help` and
248+
// add_default_flags adds the commonly used `-h`/`--help`, `--man`, and
221249
// `-v`/`--version` flags to the `Command`.
222250
fn (mut cmd Command) add_default_flags() {
223251
if cmd.defaults.parsed.help.flag && !cmd.flags.contains('help') {
@@ -233,8 +261,8 @@ fn (mut cmd Command) add_default_flags() {
233261
}
234262
}
235263

236-
// add_default_commands adds the command functions of the
237-
// commonly used `help` and `version` flags to the `Command`.
264+
// add_default_commands adds the command functions of the commonly
265+
// used `help`, `man`, and `version` subcommands to the `Command`.
238266
fn (mut cmd Command) add_default_commands() {
239267
if cmd.defaults.parsed.help.command && !cmd.commands.contains('help') && cmd.is_root() {
240268
cmd.add_command(help_cmd())
@@ -369,7 +397,7 @@ pub fn (cmd &Command) execute_help() {
369397
print(cmd.help_message())
370398
}
371399

372-
// execute_help executes the callback registered
400+
// execute_man executes the callback registered
373401
// for the `-man` flag option.
374402
pub fn (cmd &Command) execute_man() {
375403
if cmd.commands.contains('man') {

0 commit comments

Comments
 (0)