Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63e23dd

Browse files
committed
fix(clap): print usage if command is missing
Also, fixed config-dir substitution in flag's help message
1 parent 5320a48 commit 63e23dd

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/mako/cli/lib/argparse.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Configuration:
104104
CONFIG_DIR_FLAG,
105105
"A directory into which we will store our persistent data. Defaults to "
106106
"a user-writable directory that we will create during the first invocation."
107-
"[default: ${CONFIG_DIR}]",
107+
"[default: %s" % CONFIG_DIR,
108108
'folder',
109109
))
110110

src/mako/cli/lib/engine.mako

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ impl<'n, 'a> Engine<'n, 'a> {
6969
% endfor # each method
7070
_ => {
7171
err.issues.push(CLIError::MissingMethodError("${mangle_subcommand(resource)}".to_string()));
72+
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
7273
}
7374
}
7475
},
7576
% endfor # each resource
7677
_ => {
7778
err.issues.push(CLIError::MissingCommandError);
79+
writeln!(io::stderr(), "{}\n", ${SOPT}.usage()).ok();
7880
}
7981
}
8082

src/rust/cli/cmn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl fmt::Display for CLIError {
351351
writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info)
352352
},
353353
CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command"),
354-
CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the {} command", cmd),
354+
CLIError::MissingMethodError(ref cmd) => writeln!(f, "Please specify the method to call on the '{}' command", cmd),
355355
}
356356
}
357357
}

0 commit comments

Comments
 (0)