diff --git a/crates/moon/src/cli/mooncake_adapter.rs b/crates/moon/src/cli/mooncake_adapter.rs index 9cb33bc5..0425443a 100644 --- a/crates/moon/src/cli/mooncake_adapter.rs +++ b/crates/moon/src/cli/mooncake_adapter.rs @@ -35,20 +35,33 @@ pub fn execute_cli( } } +pub fn execute_cli_with_inherit_stdin( + _cli: UniversalFlags, + _cmd: T, + args: &[&str], +) -> anyhow::Result { + let mut child = call_mooncake() + .args(args) + .env("MOONCAKE_ALLOW_DIRECT", "1") + .stdout(Stdio::inherit()) + .stdin(Stdio::inherit()) + .stderr(Stdio::inherit()) + .spawn()?; + + let status = child.wait()?; + if status.success() { + Ok(0) + } else { + bail!("failed to run `moon {}`", args.join(" ")) + } +} + pub fn login_cli(cli: UniversalFlags, cmd: LoginSubcommand) -> anyhow::Result { - execute_cli( - cli, - MooncakeSubcommands::Login(cmd), - &["--read-args-from-stdin"], - ) + execute_cli_with_inherit_stdin(cli, MooncakeSubcommands::Login(cmd), &["login"]) } pub fn register_cli(cli: UniversalFlags, cmd: RegisterSubcommand) -> anyhow::Result { - execute_cli( - cli, - MooncakeSubcommands::Register(cmd), - &["--read-args-from-stdin"], - ) + execute_cli_with_inherit_stdin(cli, MooncakeSubcommands::Register(cmd), &["register"]) } pub fn publish_cli(cli: UniversalFlags, cmd: PublishSubcommand) -> anyhow::Result {