Add basic cli and config file parsing

This commit is contained in:
LDprg
2023-07-13 20:02:57 +02:00
parent c7033b1750
commit 2866a1d1b2
4 changed files with 109 additions and 2 deletions

View File

@@ -7,4 +7,5 @@ default-run = "winapps-cli"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = "4.3.11"
winapps = { path = "../winapps" }

View File

@@ -1,3 +1,33 @@
fn main() {
println!("Test lib: {}", winapps::add(1, 2));
use clap::Command;
fn cli() -> Command {
Command::new("winapps-cli")
.about("The winapps-cli is a command line interface for winapps")
.subcommand_required(true)
.arg_required_else_help(true)
.allow_external_subcommands(true)
.subcommand(Command::new("check").about("Checks remote connection"))
.subcommand(Command::new("connect").about("Connects to remote"))
}
fn main() {
let cli = cli();
let matches = cli.clone().get_matches();
match matches.subcommand() {
Some(("check", _)) => {
println!("Checking remote connection");
let _config = winapps::load_config(None);
}
Some(("connect", _)) => {
println!("Connecting to remote");
}
Some((_, _)) => {
cli.about("Command not found try existing ones!")
.print_help()
.unwrap();
}
_ => unreachable!(),
}
}