From 2a0bf1cd518969f13a6666c9705522f49dc72a4e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 16 Apr 2018 10:48:45 +0200 Subject: [PATCH] Remove CLI for mainpage setting --- bin/domain/imag-wiki/src/main.rs | 44 ++++++++++---------------------- bin/domain/imag-wiki/src/ui.rs | 8 ------ 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/bin/domain/imag-wiki/src/main.rs b/bin/domain/imag-wiki/src/main.rs index 968163a3..f211fa17 100644 --- a/bin/domain/imag-wiki/src/main.rs +++ b/bin/domain/imag-wiki/src/main.rs @@ -143,6 +143,9 @@ fn idof(rt: &Runtime, wiki_name: &str) { } fn create(rt: &Runtime, wiki_name: &str) { + use libimagwiki::entry::WikiEntry; + use libimagutil::warn_result::WarnResult; + let scmd = rt.cli().subcommand_matches("create").unwrap(); // safed by clap let name = String::from(scmd.value_of("create-name").unwrap()); // safe by clap @@ -155,36 +158,10 @@ fn create(rt: &Runtime, wiki_name: &str) { ::std::process::exit(1) }); - create_in_wiki(rt, &name, &wiki, scmd, - "create-noedit", "create-editheader", "create-printid"); -} + let mut entry = wiki.create_entry(name).map_err_trace_exit_unwrap(1); -fn create_wiki(rt: &Runtime, wiki_name: &str) { - let scmd = rt.cli().subcommand_matches("create-wiki").unwrap(); // safed by clap - let wiki_name = String::from(scmd.value_of("create-wiki-name").unwrap()); // safe by clap - let main = String::from(scmd.value_of("create-wiki-mainpagename").unwrap_or("main")); - - let wiki = rt.store().create_wiki(&wiki_name, Some(&main)).map_err_trace_exit_unwrap(1); - - create_in_wiki(rt, &main, &wiki, scmd, - "create-wiki-noedit", "create-wiki-editheader", "create-wiki-printid"); -} - -fn create_in_wiki(rt: &Runtime, - entry_name: &str, - wiki: &Wiki, - scmd: &ArgMatches, - noedit_flag: &'static str, - editheader_flag: &'static str, - printid_flag: &'static str) -{ - use libimagwiki::entry::WikiEntry; - use libimagutil::warn_result::WarnResult; - - let mut entry = wiki.create_entry(entry_name).map_err_trace_exit_unwrap(1); - - if !scmd.is_present(noedit_flag) { - if scmd.is_present(editheader_flag) { + if !scmd.is_present("create-noedit") { + if scmd.is_present("create-editheader") { let _ = entry.edit_header_and_content(rt).map_err_trace_exit_unwrap(1); } else { let _ = entry.edit_content(rt).map_err_trace_exit_unwrap(1); @@ -200,7 +177,7 @@ fn create_in_wiki(rt: &Runtime, .map_warn_err_str("Safed entry") .map_err_trace_exit_unwrap(1); - if scmd.is_present(printid_flag) { + if scmd.is_present("create-printid") { let out = rt.stdout(); let mut lock = out.lock(); let id = entry.get_location(); @@ -209,6 +186,13 @@ fn create_in_wiki(rt: &Runtime, } } +fn create_wiki(rt: &Runtime, wiki_name: &str) { + let scmd = rt.cli().subcommand_matches("create-wiki").unwrap(); // safed by clap + let wiki_name = String::from(scmd.value_of("create-wiki-name").unwrap()); // safe by clap + + let wiki = rt.store().create_wiki(&wiki_name).map_err_trace_exit_unwrap(1); +} + fn show(rt: &Runtime, wiki_name: &str) { use filters::filter::Filter; diff --git a/bin/domain/imag-wiki/src/ui.rs b/bin/domain/imag-wiki/src/ui.rs index 171f427b..17b0edc0 100644 --- a/bin/domain/imag-wiki/src/ui.rs +++ b/bin/domain/imag-wiki/src/ui.rs @@ -72,14 +72,6 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .value_name("NAME") .help("Name of the wiki")) - .arg(Arg::with_name("create-wiki-mainpagename") - .long("mainpage") - .short("M") - .takes_value(true) - .required(false) - .multiple(false) - .help("Name of the main page. Currently only for the first page to be created. Defaults to 'main'.")) - .arg(Arg::with_name("create-wiki-noedit") .long("no-edit") .short("E")