summaryrefslogtreecommitdiffstats
path: root/imag-store
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-01-23 16:01:17 +0100
committerMatthias Beyer <mail@beyermatthias.de>2016-02-09 13:45:13 +0100
commit2c876a371491a4d5f19187c287ffe0f13bf9d0d9 (patch)
tree5c79f09a08141175353b8cae98dcd5b908b940b5 /imag-store
parent86e810cc43d307ebcd6b75da03545de4ed02d0a4 (diff)
Add interface builder function
Diffstat (limited to 'imag-store')
-rw-r--r--imag-store/src/main.rs4
-rw-r--r--imag-store/src/ui.rs109
2 files changed, 113 insertions, 0 deletions
diff --git a/imag-store/src/main.rs b/imag-store/src/main.rs
index 3b8165e9..f8e382c5 100644
--- a/imag-store/src/main.rs
+++ b/imag-store/src/main.rs
@@ -7,6 +7,10 @@ extern crate libimagrt;
extern crate libimagstore;
extern crate libimagutil;
+mod ui;
+
+use ui::build_ui;
+
fn main() {
println!("Hello, world!");
}
diff --git a/imag-store/src/ui.rs b/imag-store/src/ui.rs
new file mode 100644
index 00000000..b7ac4e16
--- /dev/null
+++ b/imag-store/src/ui.rs
@@ -0,0 +1,109 @@
+use clap::{Arg, App, SubCommand};
+
+pub fn build_ui<'a>(app: App<'a, 'a, 'a, 'a, 'a, 'a>) -> App<'a, 'a, 'a, 'a, 'a, 'a> {
+ app.subcommand(SubCommand::with_name("create")
+ .about("Create an entry from the store")
+ .version("0.1")
+ .arg(Arg::with_name("path")
+ .long("path")
+ .short("p")
+ .takes_value(true)
+ .required(true)
+ .help("Create at this store path"))
+ .arg(Arg::with_name("from-raw")
+ .long("from-raw")
+ .takes_value(true)
+ .help("Create a new entry by reading this file ('-' for stdin)"))
+ .subcommand(SubCommand::with_name("entry")
+ .about("Create an entry via commandline")
+ .version("0.1")
+ .arg(Arg::with_name("content")
+ .long("content")
+ .short("c")
+ .takes_value(true)
+ .help("Content for the Entry from this file ('-' for stdin)"))
+ .arg(Arg::with_name("header")
+ .long("header")
+ .short("h")
+ .takes_value(true)
+ .multiple(true)
+ .help("Set a header field. Specify as 'header.field.value=value', multiple allowed"))
+ )
+ )
+
+ .subcommand(SubCommand::with_name("retrieve")
+ .about("Get an entry from the store")
+ .version("0.1")
+ .arg(Arg::with_name("id")
+ .long("id")
+ .short("i")
+ .takes_value(true)
+ .required(true)
+ .help("Retreive by Store Path, where root (/) is the store itself"))
+ .arg(Arg::with_name("content")
+ .long("content")
+ .short("c")
+ .help("Print content"))
+ .arg(Arg::with_name("header")
+ .long("header")
+ .short("h")
+ .help("Print header"))
+ .arg(Arg::with_name("header-json")
+ .long("header-json")
+ .short("j")
+ .help("Print header as json"))
+ .arg(Arg::with_name("raw")
+ .long("raw")
+ .short("r")
+ .help("Print Entries as they are in the store"))
+ .subcommand(SubCommand::with_name("filter-header")
+ .about("Retrieve Entries by filtering")
+ .version("0.1")
+ .arg(Arg::with_name("header-field-where")
+ .long("where")
+ .short("w")
+ .takes_value(true)
+ .help("Filter with 'header.field=foo' where the header field 'header.field' equals 'foo'")
+ )
+ .arg(Arg::with_name("header-field-grep")
+ .long("grep")
+ .short("g")
+ .takes_value(true)
+ .help("Filter with 'header.field=[a-zA-Z0-9]*' where the header field 'header.field' matches '[a-zA-Z0-9]*'"))
+ )
+ )
+
+ .subcommand(SubCommand::with_name("update")
+ .about("Get an entry from the store")
+ .version("0.1")
+ .arg(Arg::with_name("id")
+ .long("id")
+ .short("i")
+ .takes_value(true)
+ .required(true)
+ .help("Update Store Entry with this path. Root (/) is the store itself"))
+ .arg(Arg::with_name("content")
+ .long("content")
+ .short("c")
+ .takes_value(true)
+ .help("Take the content for the new Entry from this file ('-' for stdin)"))
+ .arg(Arg::with_name("header")
+ .long("header")
+ .short("h")
+ .takes_value(true)
+ .multiple(true)
+ .help("Set a header field. Specify as 'header.field.value=value', multiple allowed"))
+ )
+
+ .subcommand(SubCommand::with_name("delete")
+ .about("Delete an entry from the store")
+ .version("0.1")
+ .arg(Arg::with_name("id")
+ .long("id")
+ .short("i")
+ .takes_value(true)
+ .required(true)
+ .help("Remove Store Entry with this path. Root (/) is the store itself"))
+ )
+}
+