aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/main.rs53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs
index 79242a7..c4e1b1f 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -16,7 +16,7 @@ use std::{
use std::fs;
use std::collections::HashMap;
use chrono::{Utc, TimeZone};
-use std::env::args;
+use clap::{Parser, Subcommand};
// TODO
use git::*;
@@ -163,36 +163,39 @@ fn create_new_bug() {
read_tree(&save_current_tree);
}
-fn print_usage() {
- println!("usage: future-me <command>\n");
- println!("commands:");
- println!("show - shows the log");
- println!("new - enter new bug");
- println!("help - get this help");
+
+#[derive(Parser)]
+#[command(
+ name = "future-me",
+ version,
+ about = "A distributed git based bug tracker",
+)]
+struct Cli {
+ #[command(subcommand)]
+ command: Commands,
}
-enum Cmd{
+#[derive(Subcommand)]
+enum Commands {
Show,
New,
-}
-
-fn process_args() -> Cmd {
- let myargs: Vec<String> = args().collect();
- println!("{:?}", myargs);
- if myargs.len() != 2 {
- print_usage();
- }
- let unwraped = myargs.get(1).unwrap();
- match unwraped.as_str() {
- "show" => Cmd::Show,
- "new" => Cmd::New,
- _ => {print_usage(); todo!()},
- }
+ Reply {
+ hash: String,
+ },
}
fn main() {
- match process_args() {
- Cmd::Show => show(),
- Cmd::New => create_new_bug(),
+ let cli = Cli::parse();
+
+ match cli.command {
+ Commands::Show => {
+ show();
+ }
+ Commands::New => {
+ create_new_bug();
+ }
+ Commands::Reply { hash } => {
+ println!("Replying with: {}", hash);
+ }
}
}