From 9b768689d22dc35faa3e1df325cbb1a7ea09459e Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Sat, 16 Aug 2025 06:09:09 +0200 Subject: [PATCH] Some changes Signed-off-by: Nikolai Rodionov --- Cargo.lock | 1 + plux/src/collection.rs | 16 +--------------- pluxtl/Cargo.toml | 1 + pluxtl/src/main.rs | 23 ++++++++++++++++++++++- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df8d387..a343c09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,6 +477,7 @@ version = "0.1.0" dependencies = [ "clap", "plux", + "toml", ] [[package]] diff --git a/plux/src/collection.rs b/plux/src/collection.rs index aeabba5..0696203 100644 --- a/plux/src/collection.rs +++ b/plux/src/collection.rs @@ -1,7 +1,4 @@ -use std::fs::read_to_string; - use git2::Repository; - use crate::config; pub struct Collection { @@ -22,17 +19,6 @@ pub struct Maintainer { } pub fn add_collection(url: String) -> Result<(), std::io::Error> { - /* - * Clone the repo by url to the collections folder - * Check if there is a collection.toml in the folder - * Try to parse it - * If works, check files - * If everything is fine, put to the collections - */ - // Clone the repo to the $COLLECTIONS folder - // Check if there is a collection.toml file - // Read the collection toml file and verify files - // Add the plugins to the index file let cfg = match config::read_config() { Ok(res) => res, Err(e) => todo!(), @@ -49,7 +35,7 @@ pub fn add_collection(url: String) -> Result<(), std::io::Error> { Ok(repo) => repo, Err(e) => panic!("failed to clone: {}", e), }; - println!("{}", repo.path()) + println!("{}", repo.path().to_str().unwrap()); todo!() } diff --git a/pluxtl/Cargo.toml b/pluxtl/Cargo.toml index dd4cd1e..dc51672 100644 --- a/pluxtl/Cargo.toml +++ b/pluxtl/Cargo.toml @@ -6,3 +6,4 @@ edition = "2024" [dependencies] clap = { version = "4.5.45", features = ["derive"] } plux = { path = "../plux" } +toml = "0.9.5" diff --git a/pluxtl/src/main.rs b/pluxtl/src/main.rs index 8058af1..dfc2e44 100644 --- a/pluxtl/src/main.rs +++ b/pluxtl/src/main.rs @@ -1,6 +1,6 @@ use std::{path::PathBuf}; use clap::{Parser, Subcommand}; -use plux::collection; +use plux::{collection, config}; #[derive(Parser)] #[command(version, about, long_about = None)] @@ -28,6 +28,11 @@ enum Commands { subcommands: CollectionCommands, }, Plugin, + Config { + #[command(subcommand)] + subcommands: ConfigCommands, + + } } #[derive(Subcommand)] @@ -37,6 +42,10 @@ enum CollectionCommands { url: String }, } +#[derive(Subcommand)] +enum ConfigCommands { + Show +} fn run(url: &str) { collection::add_collection(url.to_string()); @@ -77,7 +86,19 @@ fn main() { CollectionCommands::Add { url } => run(&url), }, Commands::Plugin => todo!(), + Commands::Config { subcommands } => match subcommands { + ConfigCommands::Show => show_config(), + }, } // Continued program logic goes here... } + +fn show_config() { + let cfg = match config::read_config() { + Ok(res) => res, + Err(e) => todo!(), + }; + let cfg_toml = toml::to_string(&cfg).unwrap(); + println!("{}", cfg_toml) +}