Skip to content

Commit

Permalink
version command added
Browse files Browse the repository at this point in the history
Signed-off-by: Emre YILMAZ <[email protected]>
  • Loading branch information
delirehberi committed May 27, 2024
1 parent f2a3ae8 commit 602b728
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ struct Config{
repo_path: String,
}
const APP_NAME: &str = "tiller";
const APP_VERSION: &str = "v0.0.1";

fn main() -> io::Result<()> {

let args: Vec<String> = std::env::args().collect();
check_args(&args)?;

let config = config()?;

let Config { editor, til_folder, repo_path } = config;
Expand Down Expand Up @@ -108,3 +113,19 @@ fn get_content(editor: String) -> io::Result<String>{

read_to_string(temp_path)
}

fn check_args(args: &[String]) ->io::Result<()> {
match args.get(1) {
Some(t) => run(&t, &args[2..]),
_ => Ok(())
}
}

fn run(command: &str, args: &[String])-> io::Result<()>{
match command {
"--version" => println!("{} Version {}",APP_NAME, APP_VERSION),
_ => println!("Command is not registered {}",command)
}

std::process::exit(1)
}

0 comments on commit 602b728

Please sign in to comment.