Merge pull request #1078 from matthiasbeyer/imag-tag/positional-args

Transform UI to use positional args
This commit is contained in:
Matthias Beyer 2017-09-17 09:48:30 +02:00 committed by GitHub
commit d97b77c30c
2 changed files with 13 additions and 12 deletions

View file

@ -270,7 +270,7 @@ mod tests {
fn test_tag_add_adds_tag() { fn test_tag_add_adds_tag() {
setup_logging(); setup_logging();
debug!("Generating runtime"); debug!("Generating runtime");
let rt = generate_test_runtime(vec!["--id", "test", "--add", "foo"]).unwrap(); let rt = generate_test_runtime(vec!["test", "--add", "foo"]).unwrap();
debug!("Creating default entry"); debug!("Creating default entry");
create_test_default_entry(&rt, "test").unwrap(); create_test_default_entry(&rt, "test").unwrap();
@ -299,7 +299,7 @@ mod tests {
fn test_tag_add_more_than_remove_adds_tags() { fn test_tag_add_more_than_remove_adds_tags() {
setup_logging(); setup_logging();
debug!("Generating runtime"); debug!("Generating runtime");
let rt = generate_test_runtime(vec!["--id", "test", let rt = generate_test_runtime(vec!["test",
"--add", "foo", "--add", "foo",
"--add", "bar", "--add", "bar",
"--add", "baz", "--add", "baz",
@ -334,7 +334,7 @@ mod tests {
fn test_tag_remove_removes_tag() { fn test_tag_remove_removes_tag() {
setup_logging(); setup_logging();
debug!("Generating runtime"); debug!("Generating runtime");
let rt = generate_test_runtime(vec!["--id", "test", "--remove", "foo"]).unwrap(); let rt = generate_test_runtime(vec!["test", "--remove", "foo"]).unwrap();
debug!("Creating default entry"); debug!("Creating default entry");
create_test_default_entry(&rt, "test").unwrap(); create_test_default_entry(&rt, "test").unwrap();
@ -361,7 +361,7 @@ mod tests {
fn test_tag_remove_removes_only_to_remove_tag() { fn test_tag_remove_removes_only_to_remove_tag() {
setup_logging(); setup_logging();
debug!("Generating runtime"); debug!("Generating runtime");
let rt = generate_test_runtime(vec!["--id", "test", "--remove", "foo"]).unwrap(); let rt = generate_test_runtime(vec!["test", "--remove", "foo"]).unwrap();
debug!("Creating default entry"); debug!("Creating default entry");
create_test_default_entry(&rt, "test").unwrap(); create_test_default_entry(&rt, "test").unwrap();
@ -388,7 +388,7 @@ mod tests {
fn test_tag_remove_removes_but_doesnt_crash_on_nonexistent_tag() { fn test_tag_remove_removes_but_doesnt_crash_on_nonexistent_tag() {
setup_logging(); setup_logging();
debug!("Generating runtime"); debug!("Generating runtime");
let rt = generate_test_runtime(vec!["--id", "test", "--remove", "foo", "--remove", "bar"]).unwrap(); let rt = generate_test_runtime(vec!["test", "--remove", "foo", "--remove", "bar"]).unwrap();
debug!("Creating default entry"); debug!("Creating default entry");
create_test_default_entry(&rt, "test").unwrap(); create_test_default_entry(&rt, "test").unwrap();

View file

@ -23,12 +23,12 @@ use libimagentrytag::tag::is_tag;
pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
app.arg(Arg::with_name("id") app.arg(Arg::with_name("id")
.long("id") .index(1)
.short("i")
.takes_value(true) .takes_value(true)
.required(true) .required(true)
.help("Use this entry") .multiple(false)
.value_name("ID")) .value_name("ID")
.help("Entry to use"))
.arg(Arg::with_name("add-tags") .arg(Arg::with_name("add-tags")
.short("a") .short("a")
@ -37,15 +37,16 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.value_name("tags") .value_name("tags")
.multiple(true) .multiple(true)
.validator(is_tag) .validator(is_tag)
.help("Add tags, seperated by comma or by specifying multiple times")) .help("Add these tags"))
.arg(Arg::with_name("remove-tags") .arg(Arg::with_name("remove-tags")
.short("r") .short("r")
.long("remove") .long("remove")
.takes_value(true) .takes_value(true)
.value_name("tags")
.multiple(true) .multiple(true)
.validator(is_tag) .validator(is_tag)
.help("Remove tags, seperated by comma or by specifying multiple times")) .value_name("tags")
.help("Remove these tags"))
.subcommand(SubCommand::with_name("list") .subcommand(SubCommand::with_name("list")
.about("List tags (default)") .about("List tags (default)")