cli added
parent
1b12ecc67f
commit
9d14658fd0
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "noxis-cli"
|
name = "noxis-cli"
|
||||||
version = "0.1.0"
|
version = "0.1.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,125 @@ pub struct Cli {
|
||||||
}
|
}
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub enum Commands {
|
pub enum Commands {
|
||||||
|
#[command(
|
||||||
|
about = "To get info about current Noxis status",
|
||||||
|
)]
|
||||||
|
Status,
|
||||||
|
#[command(
|
||||||
|
about = "To start Noxis process",
|
||||||
|
)]
|
||||||
|
Start,
|
||||||
|
#[command(
|
||||||
|
about = "To stop Noxis process",
|
||||||
|
)]
|
||||||
|
Stop,
|
||||||
|
#[command(
|
||||||
|
about = "To restart Noxis process",
|
||||||
|
)]
|
||||||
|
Restart,
|
||||||
|
#[command(
|
||||||
|
about = "To get list of processes that are being monitoring",
|
||||||
|
)]
|
||||||
|
Processes,
|
||||||
|
// process command
|
||||||
|
#[command(
|
||||||
|
about = "To manage current process that is being monitoring",
|
||||||
|
)]
|
||||||
|
Process(ProcessCommand),
|
||||||
|
// config command =
|
||||||
|
#[command(
|
||||||
|
about = "To manage config settings",
|
||||||
|
)]
|
||||||
|
Config(ConfigCommand),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
pub struct ConfigCommand {
|
||||||
|
#[command(subcommand)]
|
||||||
|
action : ConfigAction,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Subcommand)]
|
||||||
|
pub enum ConfigAction {
|
||||||
|
#[command(
|
||||||
|
about = "To change current Noxis configuration",
|
||||||
|
)]
|
||||||
|
Local(LocalConfig),
|
||||||
|
#[command(
|
||||||
|
about = "To change credentials of the remote config server",
|
||||||
|
)]
|
||||||
|
Remote,
|
||||||
|
#[command(
|
||||||
|
about = "To reset all config settings",
|
||||||
|
)]
|
||||||
|
Reset,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
pub struct LocalConfig {
|
||||||
|
// flag
|
||||||
|
#[arg(
|
||||||
|
long = "json",
|
||||||
|
action,
|
||||||
|
help = "to read following input as JSON",
|
||||||
|
)]
|
||||||
|
type_of_entry : bool,
|
||||||
|
// value
|
||||||
|
#[arg(
|
||||||
|
help = "path to config file or config String (with --json flag)",
|
||||||
|
)]
|
||||||
|
config : String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
pub struct ProcessCommand {
|
||||||
|
#[arg(
|
||||||
|
help = "name of needed process",
|
||||||
|
)]
|
||||||
|
process : String,
|
||||||
|
#[command(
|
||||||
|
subcommand,
|
||||||
|
help = "To get current process's status",
|
||||||
|
)]
|
||||||
|
action : ProcessAction,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Subcommand)]
|
||||||
|
enum ProcessAction {
|
||||||
|
#[command(
|
||||||
|
about = "To get info about current process status",
|
||||||
|
)]
|
||||||
|
Status,
|
||||||
|
#[command(
|
||||||
|
about = "To start current process",
|
||||||
|
)]
|
||||||
|
Start,
|
||||||
|
#[command(
|
||||||
|
about = "To stop current process",
|
||||||
|
)]
|
||||||
|
Stop,
|
||||||
|
#[command(
|
||||||
|
about = "To freeze (hybernaze) current process",
|
||||||
|
)]
|
||||||
|
Freeze,
|
||||||
|
#[command(
|
||||||
|
about = "To unfreeze (unhybernaze) current process",
|
||||||
|
)]
|
||||||
|
Unfreeze,
|
||||||
|
#[command(
|
||||||
|
about = "To restart current process",
|
||||||
|
)]
|
||||||
|
Restart,
|
||||||
|
#[command(
|
||||||
|
about = "To get info about current process's dependencies",
|
||||||
|
)]
|
||||||
|
Deps,
|
||||||
|
#[command(
|
||||||
|
about = "To get info about current process's files-dependencies",
|
||||||
|
)]
|
||||||
|
Files,
|
||||||
|
#[command(
|
||||||
|
about = "To get info about current process's services-dependencies",
|
||||||
|
)]
|
||||||
|
Services,
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
mod cli;
|
mod cli;
|
||||||
|
|
||||||
fn main() {
|
use clap::Parser;
|
||||||
println!("Hello, world!");
|
use cli::Cli;
|
||||||
|
|
||||||
|
fn main() -> Result<(), std::io::Error>{
|
||||||
|
let cli = Cli::parse();
|
||||||
|
dbg!(&cli);
|
||||||
|
println!("{:?}", cli);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue