mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-14 18:57:02 +05:30
refactor: switch to argv for argument handling
This commit is contained in:
parent
1a1e97722b
commit
a5c22063cd
3 changed files with 10 additions and 6 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -26,6 +26,12 @@ version = "1.0.57"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc"
|
||||
|
||||
[[package]]
|
||||
name = "argv"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "593b6306f88ed573d52d5d07e309317f1c5e95777bf559b2ddb33f50b7d1158d"
|
||||
|
||||
[[package]]
|
||||
name = "assay"
|
||||
version = "0.1.1"
|
||||
|
@ -86,6 +92,7 @@ name = "clipboard-substitutor"
|
|||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"argv",
|
||||
"assay",
|
||||
"clipboard-master",
|
||||
"copypasta",
|
||||
|
|
|
@ -13,6 +13,7 @@ include = ["src/**/*", "LICENSE-*", "README.md"]
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.57"
|
||||
argv = "0.1.5"
|
||||
clipboard-master = "3.1.3"
|
||||
copypasta = { version = "0.7.1", default-features = false, features = ["x11"] }
|
||||
dirs = "4.0.0"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue