Initial import
This commit is contained in:
commit
186a4e8b73
6 changed files with 453 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
target
|
218
Cargo.lock
generated
Normal file
218
Cargo.lock
generated
Normal file
|
@ -0,0 +1,218 @@
|
|||
[root]
|
||||
name = "imag"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"yaml-rust 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "advapi32-sys"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memchr 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "1.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ansi_term 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"strsim 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"yaml-rust 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
version = "0.1.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.1.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-serialize"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rustty"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "term"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "0.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-build"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
19
Cargo.toml
Normal file
19
Cargo.toml
Normal file
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "imag"
|
||||
version = "0.1.0"
|
||||
authors = ["Matthias Beyer <mail@beyermatthias.de>"]
|
||||
|
||||
[dependencies]
|
||||
log = "0.3.2"
|
||||
regex = "0.1.41"
|
||||
url = "0.2.37"
|
||||
uuid = "0.1.18"
|
||||
|
||||
yaml-rust = "0.2.2"
|
||||
|
||||
chrono = "0.2.16"
|
||||
|
||||
clap = { version = "1.4.5", features = ["yaml"] }
|
||||
rustty = "0.1.9"
|
||||
term = "0.2.12"
|
||||
|
137
etc/cli.yml
Normal file
137
etc/cli.yml
Normal file
|
@ -0,0 +1,137 @@
|
|||
name: imag
|
||||
version: 0.1
|
||||
author: Matthias Beyer <mail@beyermatthias.de>
|
||||
about: PIM-Suite for the console
|
||||
args:
|
||||
- verbose:
|
||||
short: v
|
||||
long: verbose
|
||||
help: Enable verbosity
|
||||
required: false
|
||||
|
||||
- debug:
|
||||
short: d
|
||||
long: debug
|
||||
help: Sets the level of debugging information
|
||||
required: false
|
||||
|
||||
subcommands:
|
||||
- cal:
|
||||
about: Calendar module
|
||||
version: 0.1
|
||||
author: Matthias Beyer <mail@beyermatthias.de>
|
||||
args:
|
||||
- verbose:
|
||||
short: v
|
||||
long: verbose
|
||||
help: Enable verbosity
|
||||
required: false
|
||||
|
||||
- debug:
|
||||
short: d
|
||||
long: debug
|
||||
help: Sets the level of debugging information
|
||||
required: false
|
||||
|
||||
- cont:
|
||||
about: Contact module
|
||||
version: 0.1
|
||||
author: Matthias Beyer <mail@beyermatthias.de>
|
||||
args:
|
||||
- verbose:
|
||||
short: v
|
||||
long: verbose
|
||||
help: Enable verbosity
|
||||
required: false
|
||||
|
||||
- debug:
|
||||
short: d
|
||||
long: debug
|
||||
help: Sets the level of debugging information
|
||||
required: false
|
||||
|
||||
- mail:
|
||||
about: Mail module
|
||||
version: 0.1
|
||||
author: Matthias Beyer <mail@beyermatthias.de>
|
||||
args:
|
||||
- verbose:
|
||||
short: v
|
||||
long: verbose
|
||||
help: Enable verbosity
|
||||
required: false
|
||||
|
||||
- debug:
|
||||
short: d
|
||||
long: debug
|
||||
help: Sets the level of debugging information
|
||||
required: false
|
||||
|
||||
- wiki:
|
||||
about: Wiki module
|
||||
version: 0.1
|
||||
author: Matthias Beyer <mail@beyermatthias.de>
|
||||
args:
|
||||
- verbose:
|
||||
short: v
|
||||
long: verbose
|
||||
help: Enable verbosity
|
||||
required: false
|
||||
|
||||
- debug:
|
||||
short: d
|
||||
long: debug
|
||||
help: Sets the level of debugging information
|
||||
required: false
|
||||
|
||||
- bm:
|
||||
about: Bookmark module
|
||||
version: 0.1
|
||||
author: Matthias Beyer <mail@beyermatthias.de>
|
||||
args:
|
||||
- verbose:
|
||||
short: v
|
||||
long: verbose
|
||||
help: Enable verbosity
|
||||
required: false
|
||||
|
||||
- debug:
|
||||
short: d
|
||||
long: debug
|
||||
help: Sets the level of debugging information
|
||||
required: false
|
||||
|
||||
- todo:
|
||||
about: Todo module
|
||||
version: 0.1
|
||||
author: Matthias Beyer <mail@beyermatthias.de>
|
||||
args:
|
||||
- verbose:
|
||||
short: v
|
||||
long: verbose
|
||||
help: Enable verbosity
|
||||
required: false
|
||||
|
||||
- debug:
|
||||
short: d
|
||||
long: debug
|
||||
help: Sets the level of debugging information
|
||||
required: false
|
||||
|
||||
- news:
|
||||
about: News module
|
||||
version: 0.1
|
||||
author: Matthias Beyer <mail@beyermatthias.de>
|
||||
args:
|
||||
- verbose:
|
||||
short: v
|
||||
long: verbose
|
||||
help: Enable verbosity
|
||||
required: false
|
||||
|
||||
- debug:
|
||||
short: d
|
||||
long: debug
|
||||
help: Sets the level of debugging information
|
||||
required: false
|
||||
|
67
src/cli.rs
Normal file
67
src/cli.rs
Normal file
|
@ -0,0 +1,67 @@
|
|||
extern crate clap;
|
||||
use clap::{App, ArgMatches};
|
||||
|
||||
struct ConfigBase {
|
||||
verbosity : bool,
|
||||
debugging : bool,
|
||||
}
|
||||
|
||||
pub struct ModuleConfig {
|
||||
base : ConfigBase,
|
||||
load : bool,
|
||||
}
|
||||
|
||||
impl ModuleConfig {
|
||||
pub fn new() -> ModuleConfig {
|
||||
ModuleConfig {
|
||||
base: ConfigBase {
|
||||
verbosity: false,
|
||||
debugging: false,
|
||||
},
|
||||
load: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Config {
|
||||
base : ConfigBase,
|
||||
module_configs : Vec<ModuleConfig>,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn new() -> Config {
|
||||
Config {
|
||||
base: ConfigBase {
|
||||
verbosity: false,
|
||||
debugging: false,
|
||||
},
|
||||
module_configs: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn configure(config : &mut Config) {
|
||||
let yaml = load_yaml!("../etc/cli.yml");
|
||||
let matches = App::from_yaml(yaml).get_matches();
|
||||
|
||||
parse_global_cfg(&matches, &mut config.base);
|
||||
|
||||
if let Some(matches) = matches.subcommand_matches("test") {
|
||||
if matches.is_present("verbose") {
|
||||
println!("Printing verbosely...");
|
||||
} else {
|
||||
println!("Printing normally...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_global_cfg(matches : &ArgMatches<>, config : &mut ConfigBase) {
|
||||
if matches.is_present("verbose") {
|
||||
config.verbosity = true;
|
||||
}
|
||||
|
||||
if matches.is_present("debugging") {
|
||||
config.debugging = true;
|
||||
}
|
||||
}
|
||||
|
11
src/main.rs
Normal file
11
src/main.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[macro_use] extern crate clap;
|
||||
|
||||
use cli::Config;
|
||||
|
||||
mod cli;
|
||||
|
||||
fn main() {
|
||||
let mut config = Config::new();
|
||||
cli::configure(&mut config);
|
||||
println!("Hello, world!");
|
||||
}
|
Loading…
Reference in a new issue