summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Cargo.lock218
-rw-r--r--Cargo.toml19
-rw-r--r--etc/cli.yml137
-rw-r--r--src/cli.rs67
-rw-r--r--src/main.rs11
6 files changed, 453 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..eb5a316c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+target
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 00000000..0cc7c2ee
--- /dev/null
+++ b/Cargo.lock
@@ -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"
+
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 00000000..5574f82b
--- /dev/null
+++ b/Cargo.toml
@@ -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"
+
diff --git a/etc/cli.yml b/etc/cli.yml
new file mode 100644
index 00000000..10e39dde
--- /dev/null
+++ b/etc/cli.yml
@@ -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
+
diff --git a/src/cli.rs b/src/cli.rs
new file mode 100644
index 00000000..f0d2047a
--- /dev/null
+++ b/src/cli.rs
@@ -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;
+ }
+}
+
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 00000000..ef28a5fc
--- /dev/null
+++ b/src/main.rs
@@ -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!");
+}