Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.
Rust agent-skillsclaude-codeclicode-migrationcodexffigolangjavajavascriptmcpmigrationnapiperformanceportingpyo3pythonrewriterubyrusttypescript
app front-door: name the root command when no command was recorded (#1388)
jakalijey01c48e9e1de3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6ee0f3ae..7dd9c1f0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -223,6 +223,10 @@(#1337 by @jakalijey).from one JVM start to the next. `List.of`, `Collectors.toList`, and a `toMap` or `groupingBy`given a `TreeMap` or `LinkedHashMap` supplier are not (#1343 by @jakalijey).+- `app front-door` on a CLI whose recorded cases name no command says which name answers the+ root (`commands: none (the root command is `cli`)`) and ends with the `app wire ... --command cli`+ that works, where it said `--command <name>` and `app wire` refused every name but that one.+ With recorded commands, and under `--json`, nothing changes (#1357 by @jakalijey).- `new` ends with a `spec approve` command that names the app's folder, quoted when it needs tobe, and with the paths of `spec/SPEC.md` and `spec/cases` in that folder, so the printed commandworks from where `new` was run (#1358 by @jakalijey).diff --git a/src/main.rs b/src/main.rsindex 3ae1e395..3fe65293 100644--- a/src/main.rs+++ b/src/main.rs@@ -2870,6 +2870,16 @@ fn run_app(command: AppCmd) -> Result<ExitCode> {check: !no_check,commands: &commands,})?;+ // With no recorded command, `app wire` routes the root under the app's own name, the+ // one the front door's state keeps (not always the binary's).+ let root = (outcome.api.is_empty()+ && outcome.routes.is_empty()+ && outcome.commands.is_empty())+ .then(|| {+ front_door::State::load(&repo)+ .map(|s| s.name)+ .unwrap_or_else(|_| outcome.binary.clone())+ });if json {say!("{}", serde_json::to_string_pretty(&outcome)?);} else {@@ -2898,8 +2908,8 @@ fn run_app(command: AppCmd) -> Result<ExitCode> {)} else if !outcome.routes.is_empty() {format!("requests recorded: {}", outcome.routes.join(", "))- } else if outcome.commands.is_empty() {- "commands: none (one root command)".to_string()+ } else if let Some(root) = &root {+ format!("commands: none (the root command is `{root}`)")} else {format!("commands: {}", outcome.commands.join(", "))}@@ -2918,6 +2928,12 @@ fn run_app(command: AppCmd) -> Result<ExitCode> {"Every export is still only in the original. After a unit's crate (from `bridge`) passes gate: rust-anything app wire {} <unit crate>",rust_anything::app::cli_path(&repo));+ } else if let Some(root) = &root {+ say!(+ "Every command runs the original. After a unit passes gate: rust-anything app wire {} <unit> --command {}",+ rust_anything::app::cli_path(&repo),+ rust_anything::app::cli_path(root)+ );} else if outcome.routes.is_empty() {say!("Every command runs the original. After a unit passes gate: rust-anything app wire {} <unit> --command <name>",diff --git a/tests/app.rs b/tests/app.rsindex 2d518cce..7c892bdf 100644--- a/tests/app.rs+++ b/tests/app.rs@@ -1610,6 +1610,51 @@ fn a_library_front_door_prints_one_export_in_the_singular() {);}+#[test]+fn a_front_door_with_no_commands_names_the_root_command() {+ let Some(python) = common::python() else {+ return;+ };+ let repo = one_off(+ "root-only",+ &[("cli.py", "import sys\nprint('hello', *sys.argv[1:])\n")],+ );+ let record = common::cli()+ .args(["app", "record", ".", "--no-traps", "--"])+ .args([python, "cli.py"])+ .current_dir(&repo)+ .output()+ .unwrap();+ assert!(+ record.status.success(),+ "{}",+ String::from_utf8_lossy(&record.stderr)+ );+ let out = common::cli()+ .args(["app", "front-door", ".", "--no-check"])+ .current_dir(&repo)+ .output()+ .unwrap();+ let state: serde_json::Value = serde_json::from_str(+ &std::fs::read_to_string(repo.join("rust/app/rust-anything.json")).unwrap_or_default(),+ )+ .unwrap_or_default();+ std::fs::remove_dir_all(&repo).unwrap();+ assert!(out.status.success(), "{out:?}");+ let printed = String::from_utf8_lossy(&out.stdout);+ let root = state["name"].as_str().unwrap_or_default();+ assert!(!root.is_empty(), "{state}");+ assert!(+ printed.contains(&format!("commands: none (the root command is `{root}`)")),+ "{printed}"+ );+ assert!(+ printed.contains(&format!("<unit> --command {}\n", app::cli_path(root))),+ "{printed}"+ );+ assert!(!printed.contains("<name>"), "{printed}");+}+#[test]fn app_record_keeps_a_saved_timeout_when_none_is_passed() {let Some(python) = common::python() else {