1#[macro_use] extern crate clap;
4#[macro_use] extern crate serde_derive;
5#[macro_use] extern crate text_io;
6
7extern crate chrono;
8extern crate glob;
9extern crate serde;
10extern crate serde_json;
11extern crate tempdir;
12
13use std::error::Error;
14
15mod init;
16mod note;
17mod show;
18mod rm;
19
20pub fn run() -> Result<(), Box<Error>> {
22 let cli_app = clap_app!(myapp =>
23 (version: "0.1.0")
24 (author: "Chris Wells Wood <cwwoodesq@gmail.com>")
25 (about: "A project centric note-taking application.")
26 (@subcommand init =>
27 (about: "Initialises a tacked on notes directory.")
28 )
29 (@subcommand note =>
30 (about: "Creates a new note.")
31 (@arg CONTENT: +required "Note content, wrapped in \"\".")
32 (@arg on: --on +takes_value "Tack note onto file.")
33 )
34 (@subcommand show =>
35 (about: "Show note.")
36 (@arg on: --on +takes_value "Show notes on file.")
37 )
38 (@subcommand rm =>
39 (about: "Remove note.")
40 (@arg id: -i --id +takes_value "Removes note with matching ID.")
41 )
42 ).get_matches();
43
44 match cli_app.subcommand() {
45 ("init", _) => init::run_init(),
46 ("note", Some(sub_args)) => note::run_note(sub_args),
47 ("show", Some(sub_args)) => show::run_show(sub_args),
48 ("rm", Some(sub_args)) => rm::run_rm(sub_args),
49 _ => Err(From::from(cli_app.usage())),
50 }
51}