From c1fcf226196e700df9f6ad43dc1325f5e67f0591 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 6 Mar 2016 12:42:01 +0100 Subject: [PATCH] Group Args, so we enforce that only _one_ of them can be specified --- imag-view/src/ui.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/imag-view/src/ui.rs b/imag-view/src/ui.rs index 2c5818de..619e4f27 100644 --- a/imag-view/src/ui.rs +++ b/imag-view/src/ui.rs @@ -1,4 +1,4 @@ -use clap::{Arg, App, SubCommand}; +use clap::{Arg, App, ArgGroup, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app @@ -86,6 +86,15 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .takes_value(true) // non-optional, call-string .required(false) .help("View content in custom program, for example 'libreoffice %e', replace '%e' with entry path")) + + .group(ArgGroup::with_name("viewer") + .args(&["view-in-stdout", + "view-in-ui", + "view-in-browser", + "view-in-texteditor", + "view-in-custom", + ]) + .required(false)) ) .subcommand(SubCommand::with_name("compile")