imag-wiki: implement ImagApplication
Signed-off-by: Leon Schuermann <leon@is.currently.online>
This commit is contained in:
parent
2a1e78c705
commit
e840d4502c
3 changed files with 98 additions and 29 deletions
|
@ -21,6 +21,7 @@ toml-query = "0.9.2"
|
||||||
is-match = "0.1.0"
|
is-match = "0.1.0"
|
||||||
regex = "1.1.7"
|
regex = "1.1.7"
|
||||||
filters = "0.3.0"
|
filters = "0.3.0"
|
||||||
|
failure = "0.1.5"
|
||||||
|
|
||||||
libimagentryedit = { version = "0.10.0", path = "../../../lib/entry/libimagentryedit" }
|
libimagentryedit = { version = "0.10.0", path = "../../../lib/entry/libimagentryedit" }
|
||||||
libimagentrylink = { version = "0.10.0", path = "../../../lib/entry/libimagentrylink" }
|
libimagentrylink = { version = "0.10.0", path = "../../../lib/entry/libimagentrylink" }
|
||||||
|
@ -31,3 +32,10 @@ libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagst
|
||||||
libimagwiki = { version = "0.10.0", path = "../../../lib/domain/libimagwiki" }
|
libimagwiki = { version = "0.10.0", path = "../../../lib/domain/libimagwiki" }
|
||||||
libimagutil = { version = "0.10.0", path = "../../../lib/etc/libimagutil" }
|
libimagutil = { version = "0.10.0", path = "../../../lib/etc/libimagutil" }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "libimagwikifrontend"
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "imag-wiki"
|
||||||
|
path = "src/bin.rs"
|
||||||
|
|
39
bin/domain/imag-wiki/src/bin.rs
Normal file
39
bin/domain/imag-wiki/src/bin.rs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// imag - the personal information management suite for the commandline
|
||||||
|
// Copyright (C) 2015-2019 Matthias Beyer <mail@beyermatthias.de> and contributors
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
|
#![deny(
|
||||||
|
non_camel_case_types,
|
||||||
|
non_snake_case,
|
||||||
|
path_statements,
|
||||||
|
trivial_numeric_casts,
|
||||||
|
unstable_features,
|
||||||
|
unused_allocation,
|
||||||
|
unused_import_braces,
|
||||||
|
unused_imports,
|
||||||
|
unused_must_use,
|
||||||
|
unused_mut,
|
||||||
|
unused_qualifications,
|
||||||
|
while_true,
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[macro_use] extern crate libimagrt;
|
||||||
|
|
||||||
|
simple_imag_application_binary!(libimagwikifrontend, ImagWiki);
|
|
@ -23,8 +23,9 @@ extern crate clap;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
extern crate filters;
|
extern crate filters;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
extern crate failure;
|
||||||
|
|
||||||
#[macro_use] extern crate libimagrt;
|
extern crate libimagrt;
|
||||||
extern crate libimagerror;
|
extern crate libimagerror;
|
||||||
extern crate libimagstore;
|
extern crate libimagstore;
|
||||||
extern crate libimagwiki;
|
extern crate libimagwiki;
|
||||||
|
@ -33,9 +34,11 @@ extern crate libimagentrylink;
|
||||||
extern crate libimagutil;
|
extern crate libimagutil;
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use failure::Fallible as Result;
|
||||||
|
use clap::App;
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagrt::application::ImagApplication;
|
||||||
use libimagerror::iter::TraceIterator;
|
use libimagerror::iter::TraceIterator;
|
||||||
use libimagerror::trace::MapErrTrace;
|
use libimagerror::trace::MapErrTrace;
|
||||||
use libimagerror::exit::ExitUnwrap;
|
use libimagerror::exit::ExitUnwrap;
|
||||||
|
@ -44,15 +47,14 @@ use libimagwiki::store::WikiStore;
|
||||||
use libimagentryedit::edit::{Edit, EditHeader};
|
use libimagentryedit::edit::{Edit, EditHeader};
|
||||||
|
|
||||||
mod ui;
|
mod ui;
|
||||||
use crate::ui::build_ui;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let version = make_imag_version!();
|
|
||||||
let rt = generate_runtime_setup("imag-wiki",
|
|
||||||
&version,
|
|
||||||
"Personal wiki",
|
|
||||||
build_ui);
|
|
||||||
|
|
||||||
|
/// Marker enum for implementing ImagApplication on
|
||||||
|
///
|
||||||
|
/// This is used by binaries crates to execute business logic
|
||||||
|
/// or to build a CLI completion.
|
||||||
|
pub enum ImagWiki {}
|
||||||
|
impl ImagApplication for ImagWiki {
|
||||||
|
fn run(rt: Runtime) -> Result<()> {
|
||||||
let wiki_name = rt.cli().value_of("wikiname").unwrap_or("default");
|
let wiki_name = rt.cli().value_of("wikiname").unwrap_or("default");
|
||||||
trace!("wiki_name = {}", wiki_name);
|
trace!("wiki_name = {}", wiki_name);
|
||||||
trace!("calling = {:?}", rt.cli().subcommand_name());
|
trace!("calling = {:?}", rt.cli().subcommand_name());
|
||||||
|
@ -73,7 +75,27 @@ fn main() {
|
||||||
}
|
}
|
||||||
None => warn!("No command"),
|
None => warn!("No command"),
|
||||||
} // end match scmd
|
} // end match scmd
|
||||||
} // end main
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_cli<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
|
ui::build_ui(app)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn name() -> &'static str {
|
||||||
|
env!("CARGO_PKG_NAME")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn description() -> &'static str {
|
||||||
|
"Personal wiki"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn version() -> &'static str {
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn list(rt: &Runtime, wiki_name: &str) {
|
fn list(rt: &Runtime, wiki_name: &str) {
|
||||||
let scmd = rt.cli().subcommand_matches("list").unwrap(); // safed by clap
|
let scmd = rt.cli().subcommand_matches("list").unwrap(); // safed by clap
|
Loading…
Reference in a new issue