Skip to content

Commit

Permalink
fix: a workaround to fix password issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunchen committed Jul 11, 2024
1 parent 6f94653 commit 5d11263
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions crates/moon/src/cli/mooncake_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,33 @@ pub fn execute_cli<T: Serialize>(
}
}

pub fn execute_cli_with_inherit_stdin<T: Serialize>(
_cli: UniversalFlags,
_cmd: T,
args: &[&str],
) -> anyhow::Result<i32> {
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<i32> {
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<i32> {
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<i32> {
Expand Down

0 comments on commit 5d11263

Please sign in to comment.