make it actually check folder properly
This commit is contained in:
parent
b6f252e344
commit
edf96780e7
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2840,6 +2840,7 @@ dependencies = [
|
|||||||
"docker_utils",
|
"docker_utils",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"inquire",
|
"inquire",
|
||||||
|
"log",
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -11,5 +11,6 @@ clap = { version = "4.5.35", features = ["derive"] }
|
|||||||
inquire.workspace = true
|
inquire.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
|
log.workspace = true
|
||||||
cargo = "0.88.0"
|
cargo = "0.88.0"
|
||||||
docker_utils = "0.2.3"
|
docker_utils = "0.2.3"
|
||||||
|
|||||||
@ -4,19 +4,19 @@ use std::process::Command;
|
|||||||
use clap::builder::ArgPredicate;
|
use clap::builder::ArgPredicate;
|
||||||
use clap::{Args, Parser, Subcommand};
|
use clap::{Args, Parser, Subcommand};
|
||||||
use inquire::Confirm;
|
use inquire::Confirm;
|
||||||
|
use log::{debug, info, warn};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None, flatten_help = true, propagate_version = true)]
|
||||||
#[command(propagate_version = true)]
|
|
||||||
struct GlobalArgs {
|
struct GlobalArgs {
|
||||||
#[arg(long, default_value = "./harmony")]
|
#[arg(long, default_value = "harmony")]
|
||||||
harmony_path: String,
|
harmony_path: String,
|
||||||
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Commands,
|
command: Option<Commands>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
enum Commands {
|
enum Commands {
|
||||||
Check(CheckArgs),
|
Check(CheckArgs),
|
||||||
Package(PackageArgs),
|
Package(PackageArgs),
|
||||||
@ -24,21 +24,19 @@ enum Commands {
|
|||||||
All(AllArgs),
|
All(AllArgs),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args, Clone, Debug)]
|
||||||
struct CheckArgs {
|
struct CheckArgs {
|
||||||
#[arg(long, default_value = "check.sh")]
|
#[arg(long, default_value = "check.sh")]
|
||||||
check_script_path: String,
|
check_script_path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args, Clone, Debug)]
|
||||||
struct PackageArgs {
|
struct PackageArgs {
|
||||||
#[arg(long, default_value_t = false)]
|
|
||||||
package: bool,
|
|
||||||
#[arg(long, default_value_t = false)]
|
#[arg(long, default_value_t = false)]
|
||||||
publish: bool,
|
publish: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args, Clone, Debug)]
|
||||||
struct DeployArgs {
|
struct DeployArgs {
|
||||||
#[arg(long, default_value_t = false)]
|
#[arg(long, default_value_t = false)]
|
||||||
staging: bool,
|
staging: bool,
|
||||||
@ -50,71 +48,71 @@ struct DeployArgs {
|
|||||||
smoke_test: bool,
|
smoke_test: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args, Clone, Debug)]
|
||||||
struct AllArgs {
|
struct AllArgs {
|
||||||
#[arg(long, default_value = "check.sh")]
|
#[command(flatten)]
|
||||||
check_script_path: String,
|
check: CheckArgs,
|
||||||
|
|
||||||
#[arg(long, default_value_t = false)]
|
#[command(flatten)]
|
||||||
package: bool,
|
package: PackageArgs,
|
||||||
|
|
||||||
#[arg(long, default_value_t = false)]
|
#[command(flatten)]
|
||||||
publish: bool,
|
deploy: DeployArgs,
|
||||||
|
|
||||||
#[arg(long, default_value_t = false)]
|
|
||||||
staging: bool,
|
|
||||||
|
|
||||||
#[arg(long, default_value_t = false)]
|
|
||||||
prod: bool,
|
|
||||||
|
|
||||||
#[arg(long, default_value_t = false)]
|
|
||||||
smoke_test: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
env_logger::init();
|
||||||
let cli_args = GlobalArgs::parse();
|
let cli_args = GlobalArgs::parse();
|
||||||
|
|
||||||
let harmony_path = Path::new(&args.harmony_path).try_exists();
|
let harmony_path = Path::new(&cli_args.harmony_path)
|
||||||
|
.try_exists()
|
||||||
|
.expect("couldn't check if path exists");
|
||||||
|
|
||||||
match harmony_path {
|
match harmony_path {
|
||||||
Ok(_path) => compile_harmony(args.harmony_path.clone()),
|
true => compile_harmony(cli_args.harmony_path.clone()),
|
||||||
Err(_) => todo!("implement autodetect code"),
|
false => todo!("implement autodetect code"),
|
||||||
}
|
}
|
||||||
|
|
||||||
match cli_args.command {
|
match cli_args.command {
|
||||||
Commands::Check(args) => {
|
Some(command) => match command {
|
||||||
let check_script = match Path::new(&format!("{}/{}", cli_args.harmony_path, "check.sh"))
|
Commands::Check(args) => {
|
||||||
|
let check_script = match Path::new(&format!(
|
||||||
|
"{}/{}",
|
||||||
|
cli_args.harmony_path, args.check_script_path
|
||||||
|
))
|
||||||
.try_exists()
|
.try_exists()
|
||||||
{
|
{
|
||||||
Ok(path) => path,
|
Ok(path) => path,
|
||||||
Err(_) => todo!("implement logic when couldn't find check script"),
|
Err(_) => todo!("implement logic when couldn't find check script"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let check_output = Command::new("sh")
|
let check_output = Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(check_script.to_string())
|
.arg(check_script.to_string())
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to run check script");
|
.expect("failed to run check script");
|
||||||
}
|
|
||||||
Commands::Package(args) => {
|
|
||||||
if args.publish {
|
|
||||||
todo!("implement publish logic");
|
|
||||||
}
|
}
|
||||||
todo!("implement packaging logic");
|
Commands::Package(args) => {
|
||||||
}
|
if args.publish {
|
||||||
Commands::Deploy(args) => {
|
todo!("implement publish logic");
|
||||||
if args.staging {
|
}
|
||||||
todo!("implement staging deployment");
|
todo!("implement packaging logic");
|
||||||
}
|
}
|
||||||
|
Commands::Deploy(args) => {
|
||||||
|
if args.staging {
|
||||||
|
todo!("implement staging deployment");
|
||||||
|
}
|
||||||
|
|
||||||
if args.prod {
|
if args.prod {
|
||||||
todo!("implement prod deployment");
|
todo!("implement prod deployment");
|
||||||
|
}
|
||||||
|
todo!("implement deployment logic");
|
||||||
}
|
}
|
||||||
todo!("implement deployment logic");
|
Commands::All(args) => todo!(
|
||||||
}
|
"take all previous match arms and turn them into separate functions, and call them all one after the other"
|
||||||
Commands::All(args) => todo!(
|
),
|
||||||
"take all previous match arms and turn them into separate functions, and call them all one after the other"
|
},
|
||||||
),
|
None => todo!("run interactively, ask for info on CLI"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,14 +125,14 @@ fn compile_harmony(harmony_location: String) {
|
|||||||
&cargo::core::Workspace::new(
|
&cargo::core::Workspace::new(
|
||||||
&Path::new(&format!("{}/Cargo.toml", harmony_location))
|
&Path::new(&format!("{}/Cargo.toml", harmony_location))
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
.unwrap(),
|
.expect("Couldn't find Cargo.toml in harmony dir"),
|
||||||
&gctx,
|
&gctx,
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
&cargo::ops::CompileOptions::new(&gctx, cargo::core::compiler::CompileMode::Build)
|
&cargo::ops::CompileOptions::new(&gctx, cargo::core::compiler::CompileMode::Build)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
.expect("build success");
|
.expect("build didn't go successfully");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user