Create harmony_ci_cli
This commit is contained in:
parent
7bebc58615
commit
0f968000c3
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -1463,6 +1463,17 @@ dependencies = [
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "harmony_ci_cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"assert_cmd",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"inquire",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "harmony_cli"
|
||||
version = "0.1.0"
|
||||
|
@ -10,7 +10,7 @@ members = [
|
||||
"opnsense-config",
|
||||
"opnsense-config-xml",
|
||||
"harmony_cli",
|
||||
"k3d",
|
||||
"k3d", "harmony_ci_cli",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
|
13
harmony_ci_cli/Cargo.toml
Normal file
13
harmony_ci_cli/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "harmony_ci_cli"
|
||||
edition = "2024"
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
assert_cmd = "2.0.17"
|
||||
clap = { version = "4.5.35", features = ["derive"] }
|
||||
inquire.workspace = true
|
||||
tokio.workspace = true
|
||||
env_logger.workspace = true
|
79
harmony_ci_cli/src/main.rs
Normal file
79
harmony_ci_cli/src/main.rs
Normal file
@ -0,0 +1,79 @@
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use clap::Parser;
|
||||
use clap::builder::ArgPredicate;
|
||||
use inquire::Confirm;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
#[arg(short, long, default_value = "./harmony")]
|
||||
harmony_path: String,
|
||||
|
||||
#[arg(short, long, default_value_t = false, group = "check")]
|
||||
check: bool,
|
||||
|
||||
#[arg(short, long, default_value_t = false, group = "package")]
|
||||
package: bool,
|
||||
|
||||
#[arg(short, long, default_value_t = false, group = "package")]
|
||||
publish: bool,
|
||||
|
||||
#[arg(short, long, default_value_t = false, group = "deploy")]
|
||||
deploy: bool,
|
||||
|
||||
#[arg(short, long, default_value_t = false, group = "deploy")]
|
||||
staging: bool,
|
||||
|
||||
#[arg(short, long, default_value_t = false, group = "deploy")]
|
||||
prod: bool,
|
||||
|
||||
#[arg(short, long, default_value_t = false, group = "deploy")]
|
||||
smoke_test: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
let harmony_path = Path::new(&args.harmony_path).try_exists();
|
||||
|
||||
match harmony_path {
|
||||
Ok(_path) => {
|
||||
todo!("implement cargo check and compile harmony_cli/UI binary in harmony dir")
|
||||
}
|
||||
Err(_) => todo!("implement autodetect code"),
|
||||
}
|
||||
|
||||
if args.check {
|
||||
let check_script =
|
||||
match Path::new(&format!("{}/{}", args.harmony_path, "check.sh")).try_exists() {
|
||||
Ok(path) => path,
|
||||
Err(_) => todo!("implement logic when couldn't find check script"),
|
||||
};
|
||||
|
||||
let check_output = Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(check_script.to_string())
|
||||
.output()
|
||||
.expect("failed to run check script");
|
||||
}
|
||||
|
||||
if args.package {
|
||||
if args.publish {
|
||||
todo!("implement publish logic");
|
||||
}
|
||||
todo!("implement packaging logic");
|
||||
}
|
||||
|
||||
if args.deploy {
|
||||
if args.staging {
|
||||
todo!("implement staging deployment");
|
||||
}
|
||||
|
||||
if args.prod {
|
||||
todo!("implement prod deployment");
|
||||
}
|
||||
todo!("implement deployment logic");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user