2016-10-01 15:35:06 +00:00
|
|
|
//
|
|
|
|
// imag - the personal information management suite for the commandline
|
2018-02-07 01:48:53 +00:00
|
|
|
// Copyright (C) 2015-2018 Matthias Beyer <mail@beyermatthias.de> and contributors
|
2016-10-01 15:35:06 +00:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; version
|
|
|
|
// 2.1 of the License.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
//
|
|
|
|
|
2016-03-07 17:51:53 +00:00
|
|
|
use clap::{Arg, App, ArgGroup, SubCommand};
|
2016-01-23 15:01:17 +00:00
|
|
|
|
2016-02-20 20:21:51 +00:00
|
|
|
pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
2016-01-23 15:01:17 +00:00
|
|
|
app.subcommand(SubCommand::with_name("create")
|
|
|
|
.about("Create an entry from the store")
|
|
|
|
.version("0.1")
|
|
|
|
.arg(Arg::with_name("path")
|
2017-09-04 14:33:54 +00:00
|
|
|
.index(1)
|
2016-01-23 15:01:17 +00:00
|
|
|
.takes_value(true)
|
2017-09-04 14:33:54 +00:00
|
|
|
.required(true)
|
2016-06-08 12:11:13 +00:00
|
|
|
.help("Create at this store path")
|
|
|
|
.value_name("PATH"))
|
2016-01-23 15:01:17 +00:00
|
|
|
.arg(Arg::with_name("from-raw")
|
|
|
|
.long("from-raw")
|
|
|
|
.takes_value(true)
|
2016-06-08 12:11:13 +00:00
|
|
|
.help("Create a new entry by reading this file ('-' for stdin)")
|
|
|
|
.value_name("FILE"))
|
2016-03-07 17:51:53 +00:00
|
|
|
|
2016-01-23 15:01:17 +00:00
|
|
|
.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)
|
2016-06-08 12:11:13 +00:00
|
|
|
.help("Content for the Entry from commandline")
|
|
|
|
.value_name("CONTENT"))
|
2016-01-31 11:37:40 +00:00
|
|
|
.arg(Arg::with_name("content-from")
|
|
|
|
.long("content-from")
|
|
|
|
.short("f")
|
|
|
|
.takes_value(true)
|
2016-06-08 12:11:13 +00:00
|
|
|
.help("Content for the Entry from this file ('-' for stdin)")
|
|
|
|
.value_name("CONTENT"))
|
2016-03-07 17:51:53 +00:00
|
|
|
|
|
|
|
.group(ArgGroup::with_name("create-content-group")
|
|
|
|
.args(&["content", "content-from"])
|
|
|
|
.required(false))
|
|
|
|
|
2016-01-23 15:01:17 +00:00
|
|
|
.arg(Arg::with_name("header")
|
|
|
|
.long("header")
|
|
|
|
.short("h")
|
|
|
|
.takes_value(true)
|
|
|
|
.multiple(true)
|
2016-06-08 12:11:13 +00:00
|
|
|
.help("Set a header field. Specify as 'header.field.value=value', multiple allowed")
|
|
|
|
.value_name("header.field.value=value"))
|
2016-01-23 15:01:17 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
.subcommand(SubCommand::with_name("retrieve")
|
2016-05-27 09:25:43 +00:00
|
|
|
.about("Retrieve an entry from the store (implicitely creates the entry)")
|
|
|
|
.version("0.1")
|
|
|
|
.arg(Arg::with_name("id")
|
2017-09-04 14:42:31 +00:00
|
|
|
.index(1)
|
2016-05-27 09:25:43 +00:00
|
|
|
.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("get")
|
|
|
|
.about("Get an entry from the store (fails if non-existent)")
|
2016-01-23 15:01:17 +00:00
|
|
|
.version("0.1")
|
|
|
|
.arg(Arg::with_name("id")
|
2017-09-04 14:44:23 +00:00
|
|
|
.index(1)
|
2016-01-23 15:01:17 +00:00
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
2016-06-08 12:11:13 +00:00
|
|
|
.help("Retrieve by Store Path, where root (/) is the store itself")
|
|
|
|
.value_name("PATH"))
|
2016-01-23 15:01:17 +00:00
|
|
|
.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"))
|
2016-03-07 17:51:53 +00:00
|
|
|
|
2016-01-23 15:01:17 +00:00
|
|
|
.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'")
|
2016-06-08 12:11:13 +00:00
|
|
|
.value_name("header.field=foo")
|
2016-01-23 15:01:17 +00:00
|
|
|
)
|
|
|
|
.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)
|
2016-06-08 12:11:13 +00:00
|
|
|
.help("Update Store Entry with this path. Root (/) is the store itself")
|
|
|
|
.value_name("PATH"))
|
2016-01-23 15:01:17 +00:00
|
|
|
.arg(Arg::with_name("content")
|
|
|
|
.long("content")
|
|
|
|
.short("c")
|
|
|
|
.takes_value(true)
|
2016-06-08 12:11:13 +00:00
|
|
|
.help("Take the content for the new Entry from this file ('-' for stdin)")
|
|
|
|
.value_name("CONTENT"))
|
2016-01-23 15:01:17 +00:00
|
|
|
.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")
|
2017-09-04 14:51:18 +00:00
|
|
|
.index(1)
|
2016-01-23 15:01:17 +00:00
|
|
|
.takes_value(true)
|
|
|
|
.required(true)
|
2016-06-08 12:11:13 +00:00
|
|
|
.help("Remove Store Entry with this path. Root (/) is the store itself")
|
|
|
|
.value_name("PATH"))
|
2016-01-23 15:01:17 +00:00
|
|
|
)
|
2016-07-16 22:45:51 +00:00
|
|
|
|
|
|
|
.subcommand(SubCommand::with_name("verify")
|
|
|
|
.about("Verify the store")
|
|
|
|
.version("0.1")
|
|
|
|
)
|
2017-06-18 16:56:49 +00:00
|
|
|
|
|
|
|
.subcommand(SubCommand::with_name("dump")
|
|
|
|
.about("Dump the complete store to stdout. Currently does only support JSON")
|
|
|
|
.version("0.1")
|
|
|
|
)
|
2017-10-08 15:26:18 +00:00
|
|
|
.subcommand(SubCommand::with_name("ids")
|
|
|
|
.about("List of Storeids")
|
|
|
|
.version("0.1")
|
|
|
|
.arg(Arg::with_name("full")
|
|
|
|
.long("full")
|
|
|
|
.short("F")
|
|
|
|
.takes_value(false)
|
|
|
|
.multiple(false)
|
|
|
|
.required(false)
|
|
|
|
.help("Print full filepath instead of storeid part"))
|
|
|
|
)
|
2016-01-23 15:01:17 +00:00
|
|
|
}
|