refactor: switch to argv for argument handling

This commit is contained in:
Harsh Shandilya 2022-05-01 18:12:41 +05:30
parent 1a1e97722b
commit a5c22063cd
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
3 changed files with 10 additions and 6 deletions

View file

@ -3,7 +3,6 @@ mod config;
#[cfg(test)]
mod test;
use std::ops::Deref;
use std::path::PathBuf;
use anyhow::{anyhow, Result};
@ -12,8 +11,6 @@ use dirs::config_dir;
use crate::clipboard::monitor_clipboard;
use crate::config::Replacements;
const VERSION_ARGS: [&str; 3] = ["version", "-v", "--version"];
fn main() -> Result<()> {
if check_for_version_arg() {
return Ok(());
@ -28,9 +25,8 @@ fn main() -> Result<()> {
}
fn check_for_version_arg() -> bool {
let args: Vec<String> = std::env::args().collect();
for arg in args {
if VERSION_ARGS.contains(&arg.deref()) {
for arg in argv::iter() {
if arg == "-v" || arg == "version" || arg == "--version" {
print_version();
return true;
}