aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDenis Evsyukov <[email protected]>2020-03-07 18:46:45 +0300
committerDenis Evsyukov <[email protected]>2020-03-07 18:46:45 +0300
commit101d877bf713df10c58968b80b0712477fad7bf3 (patch)
tree620ac5e4114f84264cd78947387a4c9c20338ef5 /src/main.rs
parent[+] added important note (diff)
downloadt-101d877bf713df10c58968b80b0712477fad7bf3.tar.xz
t-101d877bf713df10c58968b80b0712477fad7bf3.zip
[+] getopts
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..88027c7
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,43 @@
+extern crate getopts;
+
+use getopts::*;
+use std::env;
+
+fn main() {
+ let args: Vec<String> = env::args().collect();
+ let mut opts = Options::new();
+ opts.optflag("h", "help", "Show this help screen");
+ opts.optflag("", "done", "list done tasks instead of unfinished ones");
+ opts.optopt("e", "edit", "edit TASK to contain TEXT", "TASK");
+ opts.optopt("f", "finish", "mark TASK as finished", "TASK");
+ opts.optopt("r", "remove", "Remove TASK from list", "TASK");
+ opts.optopt("l", "list", "work on LIST", "LIST");
+ opts.optopt("t", "taskdir", "work on the lists in DIR", "DIR");
+ opts.optflag(
+ "d",
+ "delete-if-empty",
+ "delete the task file if it becomes empty",
+ );
+ opts.optopt("g", "grep", "print only tasks that contain WORD", "WORD");
+ opts.optflag(
+ "v",
+ "verbose",
+ "print more detailed output (full task ids, etc)",
+ );
+ opts.optflag(
+ "q",
+ "quiet",
+ "print less detailed output (no task ids, etc)",
+ );
+
+ let matches = match opts.parse(&args[1..]) {
+ Ok(m) => m,
+ Err(f) => panic!(f.to_string()),
+ };
+
+ if matches.opt_present("h") {
+ let brief = "t is for people that want do things, not organize their tasks";
+ opts.usage(&brief);
+ return;
+ }
+}