数据库的可靠集成
1. Redis 操作
1.1 参数解析
我们的命令支持三个子命令,需要将它们添加到 clap::App
实例中:
let matches = App::new(crate_name!())
.version(crate_version!())
.author(crate_authors!())
.about(crate_description!())
.setting(AppSettings::SubcommandRequired)
.arg(
Arg::with_name("database")
.short("d")
.long("db")
.value_name("ADDR")
.help("Sets an address of db connection")
.takes_value(true),
)
.subcommand(SubCommand::with_name(CMD_ADD).about("add a session")
.arg(Arg::with_name("TOKEN")
.help("Sets the token of a user")
.required(true)
.index(1))
.arg(Arg: