rustup update stable
main 函数 ExitCodeconst fn 增强let mut program = Program::new();
program
.version("0.1.0")
.description("An example CLI")
.author("Author's name");
program
.subcommand("test")
.argument("<app-name>", "Pass the name of the app to test")
.alias("t")
.description("A test command")
.option("-s --skip", "Skip checking/installing the dependencies")
.option("-p --priority", "The priority to use when testing apps")
.action(|matches| { dbg!(matches); });
// ...
program.parse();
From 日报小组 PsiACE
原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。