imag-init: implement ImagApplication
Signed-off-by: Leon Schuermann <leon@is.currently.online>
This commit is contained in:
parent
0739fed666
commit
208d6e62e6
3 changed files with 88 additions and 2 deletions
|
@ -20,6 +20,8 @@ is-it-maintained-open-issues = { repository = "matthiasbeyer/imag" }
|
|||
maintenance = { status = "actively-developed" }
|
||||
|
||||
[dependencies]
|
||||
failure = "0.1.5"
|
||||
|
||||
libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
||||
|
@ -31,3 +33,10 @@ features = ["color", "suggestions", "wrap_help"]
|
|||
[dev-dependencies]
|
||||
toml = "0.5.1"
|
||||
|
||||
[lib]
|
||||
name = "libimaginitcmd"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "imag-init"
|
||||
path = "src/bin.rs"
|
||||
|
|
46
bin/core/imag-init/src/bin.rs
Normal file
46
bin/core/imag-init/src/bin.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// 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,
|
||||
)]
|
||||
|
||||
extern crate failure;
|
||||
use failure::Fallible as Result;
|
||||
|
||||
extern crate libimaginitcmd;
|
||||
|
||||
|
||||
fn main() -> Result<()> {
|
||||
libimaginitcmd::imag_init();
|
||||
Ok(())
|
||||
}
|
|
@ -35,7 +35,7 @@
|
|||
)]
|
||||
|
||||
extern crate clap;
|
||||
|
||||
extern crate failure;
|
||||
#[cfg(test)]
|
||||
extern crate toml;
|
||||
|
||||
|
@ -53,6 +53,10 @@ use std::process::Command;
|
|||
use libimagerror::exit::ExitUnwrap;
|
||||
use libimagerror::io::ToExitCode;
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagrt::application::ImagApplication;
|
||||
|
||||
use failure::Fallible as Result;
|
||||
use clap::App;
|
||||
|
||||
const CONFIGURATION_STR : &str = include_str!("../imagrc.toml");
|
||||
|
||||
|
@ -69,7 +73,34 @@ const GITIGNORE_STR : &str = r#"
|
|||
imagrc.toml
|
||||
"#;
|
||||
|
||||
fn main() {
|
||||
/// Marker enum for implementing ImagApplication on
|
||||
///
|
||||
/// This is used by binaries crates to execute business logic
|
||||
/// or to build a CLI completion.
|
||||
pub enum ImagInit {}
|
||||
impl ImagApplication for ImagInit {
|
||||
fn run(_rt: Runtime) -> Result<()> {
|
||||
panic!("imag-init needs to be run as a seperate binary, or we'll need to figure something out here!");
|
||||
}
|
||||
|
||||
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 {
|
||||
"Intialize the imag store"
|
||||
}
|
||||
|
||||
fn version() -> &'static str {
|
||||
env!("CARGO_PKG_VERSION")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn imag_init() {
|
||||
let version = make_imag_version!();
|
||||
let app = ui::build_ui(Runtime::get_default_cli_builder(
|
||||
"imag-init",
|
Loading…
Reference in a new issue