summaryrefslogtreecommitdiffstats
path: root/imag-view
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-02-20 15:46:06 +0100
committerMatthias Beyer <mail@beyermatthias.de>2016-03-11 16:20:20 +0100
commit2e6b6b50faed750cc51687d9a3f166ed67cad0e3 (patch)
tree098f416471d5bd155a617a6b5ce731e85bfbeca0 /imag-view
parent17eb59ae29eb275c2e961cce7e982b72efa79b7f (diff)
Add ui::build_ui()
Diffstat (limited to 'imag-view')
-rw-r--r--imag-view/src/main.rs4
-rw-r--r--imag-view/src/ui.rs110
2 files changed, 114 insertions, 0 deletions
diff --git a/imag-view/src/main.rs b/imag-view/src/main.rs
index e7a11a96..2352bb00 100644
--- a/imag-view/src/main.rs
+++ b/imag-view/src/main.rs
@@ -1,3 +1,7 @@
+extern crate clap;
+
+mod ui;
+
fn main() {
println!("Hello, world!");
}
diff --git a/imag-view/src/ui.rs b/imag-view/src/ui.rs
new file mode 100644
index 00000000..2c5818de
--- /dev/null
+++ b/imag-view/src/ui.rs
@@ -0,0 +1,110 @@
+use clap::{Arg, App, SubCommand};
+
+pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
+ app
+ .arg(Arg::with_name("id")
+ .long("id")
+ .short("i")
+ .takes_value(true)
+ .required(true)
+ .help("View this entry at this store path"))
+
+ .arg(Arg::with_name("version")
+ .long("version")
+ .short("V")
+ .takes_value(true)
+ .required(false)
+ .help("View this version (youngest if not specified)"))
+
+ .arg(Arg::with_name("versions")
+ .long("versions")
+ .takes_value(false)
+ .required(false)
+ .help("Only print available versions for this file"))
+
+ .arg(Arg::with_name("view-header")
+ .long("header")
+ .short("h")
+ .takes_value(false)
+ .required(false)
+ .help("View header"))
+ .arg(Arg::with_name("view-content")
+ .long("content")
+ .short("C")
+ .takes_value(false)
+ .required(false)
+ .help("View content"))
+
+ .arg(Arg::with_name("view-copy")
+ .long("copy")
+ .takes_value(false)
+ .required(false)
+ .help("Copy before opening (copies to /tmp/) and removes the file after viewing."))
+
+ .arg(Arg::with_name("keep-copy")
+ .long("keep-copy")
+ .short("k")
+ .takes_value(false)
+ .required(false)
+ .help("If --copy was passed, keep the copy after viewing."))
+
+ .subcommand(SubCommand::with_name("view-in")
+ .about("View the entry in ...")
+ .version("0.1")
+
+ .arg(Arg::with_name("view-in-stdout")
+ .long("stdout")
+ .short("s")
+ .takes_value(false)
+ .required(false)
+ .help("View by printing to stdout"))
+
+ .arg(Arg::with_name("view-in-ui")
+ .long("ui")
+ .short("u")
+ .takes_value(false)
+ .required(false)
+ .help("View by opening own curses-like UI (default)"))
+
+ .arg(Arg::with_name("view-in-browser")
+ .long("browser")
+ .short("b")
+ .takes_value(true) // optional, which browser
+ .required(false)
+ .help("View content in $BROWSER (fails if no env variable $BROWSER)"))
+
+ .arg(Arg::with_name("view-in-texteditor")
+ .long("editor")
+ .short("e")
+ .takes_value(true) // optional, which editor
+ .required(false)
+ .help("View content in $EDITOR"))
+
+ .arg(Arg::with_name("view-in-custom")
+ .long("custom")
+ .short("c")
+ .takes_value(true) // non-optional, call-string
+ .required(false)
+ .help("View content in custom program, for example 'libreoffice %e', replace '%e' with entry path"))
+ )
+
+ .subcommand(SubCommand::with_name("compile")
+ .about("Compile content to other format for viewing, implies that the entry gets copied to /tmp")
+ .version("0.1")
+ .arg(Arg::with_name("from")
+ .long("from")
+ .short("f")
+ .takes_value(true) // "markdown" or "textile" or "restructuredtex"
+ .required(true)
+ .help("Compile from"))
+
+ .arg(Arg::with_name("to")
+ .long("to")
+ .short("t")
+ .takes_value(true) // "html" or "HTML" or ... json maybe?
+ .required(true)
+ .help("Compile to"))
+ )
+}
+
+