From e34faa6cfb1e1169f80c4de727ae1961e1f7d48e Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 3 Apr 2024 22:26:39 +0300 Subject: [PATCH] Simplified the commands parsing --- Cargo.lock | 2 +- Cargo.toml | 4 ++-- src/auth.rs | 1 + src/config.rs | 5 +---- src/lib.rs | 9 +++------ src/main.rs | 6 +++--- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e7a50c..6a69879 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1514,7 +1514,7 @@ dependencies = [ [[package]] name = "soldeer" -version = "0.2.7" +version = "0.2.8" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 92bcc80..2cc4e74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" name = "soldeer" readme = "./README.md" repository = "https://github.com/mario-eth/soldeer" -version = "0.2.7" +version = "0.2.8" [dependencies] chrono = {version = "0.4.34", features = ["serde"]} @@ -39,7 +39,7 @@ zip-extract = "0.1.3" tokio-test = "0.4.3" [lib] -name = "soldeer_lib" +name = "soldeer" path = "src/lib.rs" [[bin]] diff --git a/src/auth.rs b/src/auth.rs index cad9c00..4955292 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -75,6 +75,7 @@ pub async fn login() -> Result<(), LoginError> { .token; let mut file: std::fs::File = OpenOptions::new() .create(true) + .truncate(true) .write(true) .append(false) .open(&security_file) diff --git a/src/config.rs b/src/config.rs index 67b0c81..aa22190 100644 --- a/src/config.rs +++ b/src/config.rs @@ -21,10 +21,7 @@ use std::path::{ PathBuf, }; use std::process::exit; -use toml::{ - self, - Table, -}; +use toml::Table; use yansi::Paint; extern crate toml_edit; use std::io; diff --git a/src/lib.rs b/src/lib.rs index 2bc39fa..4961995 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,10 +10,7 @@ mod utils; mod versioning; use crate::auth::login; -use crate::commands::{ - Args, - Subcommands, -}; +use crate::commands::Subcommands; use crate::config::{ get_foundry_setup, read_config, @@ -48,8 +45,8 @@ pub struct FOUNDRY { } #[tokio::main] -pub async fn run(args: Args) -> Result<(), SoldeerError> { - match args.command { +pub async fn run(command: Subcommands) -> Result<(), SoldeerError> { + match command { Subcommands::Install(install) => { println!("{}", Paint::green("🦌 Running soldeer install 🦌\n")); if !install.dependency.contains('~') { diff --git a/src/main.rs b/src/main.rs index af42dde..2f86597 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,12 @@ -extern crate soldeer_lib; +extern crate soldeer; use yansi::Paint; -use crate::soldeer_lib::commands::Args; +use crate::soldeer::commands::Args; use clap::Parser; pub fn main() { let args = Args::parse(); - match soldeer_lib::run(args) { + match soldeer::run(args.command) { Ok(_) => {} Err(err) => { eprintln!("{}", Paint::red(err.message))