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 = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"plux",
|
"plux",
|
||||||
|
"toml",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
use std::fs::read_to_string;
|
|
||||||
|
|
||||||
use git2::Repository;
|
use git2::Repository;
|
||||||
|
|
||||||
use crate::config;
|
use crate::config;
|
||||||
|
|
||||||
pub struct Collection {
|
pub struct Collection {
|
||||||
@@ -22,17 +19,6 @@ pub struct Maintainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_collection(url: String) -> Result<(), std::io::Error> {
|
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() {
|
let cfg = match config::read_config() {
|
||||||
Ok(res) => res,
|
Ok(res) => res,
|
||||||
Err(e) => todo!(),
|
Err(e) => todo!(),
|
||||||
@@ -49,7 +35,7 @@ pub fn add_collection(url: String) -> Result<(), std::io::Error> {
|
|||||||
Ok(repo) => repo,
|
Ok(repo) => repo,
|
||||||
Err(e) => panic!("failed to clone: {}", e),
|
Err(e) => panic!("failed to clone: {}", e),
|
||||||
};
|
};
|
||||||
println!("{}", repo.path())
|
println!("{}", repo.path().to_str().unwrap());
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,3 +6,4 @@ edition = "2024"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.45", features = ["derive"] }
|
clap = { version = "4.5.45", features = ["derive"] }
|
||||||
plux = { path = "../plux" }
|
plux = { path = "../plux" }
|
||||||
|
toml = "0.9.5"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
use std::{path::PathBuf};
|
use std::{path::PathBuf};
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use plux::collection;
|
use plux::{collection, config};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
@@ -28,6 +28,11 @@ enum Commands {
|
|||||||
subcommands: CollectionCommands,
|
subcommands: CollectionCommands,
|
||||||
},
|
},
|
||||||
Plugin,
|
Plugin,
|
||||||
|
Config {
|
||||||
|
#[command(subcommand)]
|
||||||
|
subcommands: ConfigCommands,
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
@@ -37,6 +42,10 @@ enum CollectionCommands {
|
|||||||
url: String
|
url: String
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
enum ConfigCommands {
|
||||||
|
Show
|
||||||
|
}
|
||||||
|
|
||||||
fn run(url: &str) {
|
fn run(url: &str) {
|
||||||
collection::add_collection(url.to_string());
|
collection::add_collection(url.to_string());
|
||||||
@@ -77,7 +86,19 @@ fn main() {
|
|||||||
CollectionCommands::Add { url } => run(&url),
|
CollectionCommands::Add { url } => run(&url),
|
||||||
},
|
},
|
||||||
Commands::Plugin => todo!(),
|
Commands::Plugin => todo!(),
|
||||||
|
Commands::Config { subcommands } => match subcommands {
|
||||||
|
ConfigCommands::Show => show_config(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continued program logic goes here...
|
// 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