Clean up prompt and script list

This commit is contained in:
SkyfallWasTaken 2024-07-10 18:25:02 +01:00
parent b80ab66892
commit a3f9a00af5

View file

@ -8,14 +8,14 @@ pub async fn run(script_name: Option<String>) -> Result<()> {
let (package_json, package_json_path) = PackageJson::from_file(10).await?; let (package_json, package_json_path) = PackageJson::from_file(10).await?;
let root_path = package_json_path.parent().unwrap(); // Should never happen, `package.json` should always be there let root_path = package_json_path.parent().unwrap(); // Should never happen, `package.json` should always be there
match script_name {
Some(script_name) => {
let Some(scripts) = package_json.scripts else { let Some(scripts) = package_json.scripts else {
return Err(eyre!("no `scripts` provided in package.json")); return Err(eyre!("no `scripts` provided in package.json"));
}; };
match script_name {
Some(script_name) => {
match scripts.get(&script_name) { match scripts.get(&script_name) {
Some(script) => { Some(script) => {
println!("> {}", script.bold()); println!("{} {}", "$".purple().dimmed(), script.bold().dimmed());
let status = let status =
run_script(DEFAULT_SHELL, DEFAULT_SHELL_EXEC_ARG, &script, root_path) run_script(DEFAULT_SHELL, DEFAULT_SHELL_EXEC_ARG, &script, root_path)
@ -40,7 +40,10 @@ pub async fn run(script_name: Option<String>) -> Result<()> {
} }
} }
_ => { _ => {
todo!() println!("{}", "Available scripts:".bold().underline());
for (key, val) in scripts.iter() {
println!("{} - {}", key.bold(), val.dimmed())
}
} }
} }