Some changes
Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -477,6 +477,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"plux",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@@ -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!()
|
||||
}
|
||||
|
||||
|
@@ -6,3 +6,4 @@ edition = "2024"
|
||||
[dependencies]
|
||||
clap = { version = "4.5.45", features = ["derive"] }
|
||||
plux = { path = "../plux" }
|
||||
toml = "0.9.5"
|
||||
|
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user