fix: small bugs in running scripts and set default log level
This commit is contained in:
@@ -19,6 +19,7 @@ enum Commands {
|
||||
Init {},
|
||||
Template(template::Template),
|
||||
Info {},
|
||||
Clean {},
|
||||
Serve {
|
||||
#[arg(env = "FOREST_HOST", long, default_value = "127.0.0.1:3000")]
|
||||
host: SocketAddr,
|
||||
@@ -54,9 +55,7 @@ fn get_root(include_run: bool) -> clap::Command {
|
||||
);
|
||||
|
||||
if include_run {
|
||||
root_cmd = root_cmd
|
||||
.subcommand(clap::Command::new("run").allow_external_subcommands(true))
|
||||
.ignore_errors(true);
|
||||
root_cmd = root_cmd.subcommand(clap::Command::new("run").allow_external_subcommands(true));
|
||||
}
|
||||
|
||||
Commands::augment_subcommands(root_cmd)
|
||||
@@ -112,7 +111,10 @@ pub async fn execute() -> anyhow::Result<()> {
|
||||
matches
|
||||
};
|
||||
|
||||
match matches.subcommand().unwrap() {
|
||||
match matches
|
||||
.subcommand()
|
||||
.expect("forest requires a command to be passed")
|
||||
{
|
||||
("run", args) => {
|
||||
run::Run::execute(args, &project_path, &context).await?;
|
||||
}
|
||||
@@ -148,6 +150,13 @@ pub async fn execute() -> anyhow::Result<()> {
|
||||
let _url = put_object.sign(std::time::Duration::from_secs(30));
|
||||
let _state = SharedState::new().await?;
|
||||
}
|
||||
Commands::Clean {} => {
|
||||
let forest_path = project_path.join(".forest");
|
||||
if forest_path.exists() {
|
||||
tokio::fs::remove_dir_all(forest_path).await?;
|
||||
tracing::info!("removed .forest");
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -71,6 +71,6 @@ impl Run {
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
anyhow::bail!("no scripts were found for command: {}", name)
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,6 @@
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
pub mod cli;
|
||||
pub mod model;
|
||||
pub mod plan_reconciler;
|
||||
@@ -7,7 +10,14 @@ pub mod state;
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
dotenvy::dotenv().ok();
|
||||
tracing_subscriber::fmt::init();
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
EnvFilter::builder()
|
||||
.with_default_directive(LevelFilter::WARN.into())
|
||||
.with_env_var("FOREST_LOG_LEVEL")
|
||||
.from_env()?,
|
||||
)
|
||||
.init();
|
||||
|
||||
cli::execute().await?;
|
||||
|
||||
|
@@ -26,7 +26,7 @@ impl ScriptExecutor {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
anyhow::bail!("script was not found for name: {}", name)
|
||||
}
|
||||
|
||||
async fn run_project(&self, script_ctx: &Script, name: &str) -> anyhow::Result<bool> {
|
||||
|
Reference in New Issue
Block a user