From e956976a2d387b28c0760fd7bd33bc0aac73dbbe Mon Sep 17 00:00:00 2001 From: Amneesh Singh Date: Thu, 6 Apr 2023 17:14:53 +0530 Subject: [PATCH] fix clippy checks Signed-off-by: Amneesh Singh --- .envrc | 1 + .gitignore | 5 +++++ src/args.rs | 8 ++++---- src/main.rs | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .envrc create mode 100644 .gitignore diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d727777 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/target +.direnv +*~ +\#*\# +result* diff --git a/src/args.rs b/src/args.rs index a102f5b..48b9f5a 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,8 +1,8 @@ use std::env; use std::process::exit; -const VERSION: &'static str = env!("CARGO_PKG_VERSION"); -const CRATE: &'static str = env!("CARGO_CRATE_NAME"); +const VERSION: &str = env!("CARGO_PKG_VERSION"); +const CRATE: &str = env!("CARGO_CRATE_NAME"); #[derive(Default)] struct Options { @@ -24,8 +24,8 @@ pub fn handle() -> String { for arg in &args[1..] { match arg.as_str() { "-v" | "--version" => options.version = true, - flag if flag.chars().next() == Some('-') => panic!("option {} not implemented!", flag), - file @ _ => { + flag if flag.starts_with('-') => panic!("option {} not implemented!", flag), + file => { if !options.file.is_empty() { panic!("please specify only a single source file!"); } diff --git a/src/main.rs b/src/main.rs index 5b96ae2..e64bc57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use tricc::args; fn main() { - println!("Hello World!"); + let file: String = args::handle(); + println!("{}", file); }