diff --git a/wezterm/src/cli/mod.rs b/wezterm/src/cli/mod.rs index e2e1fa879..13b4738b0 100644 --- a/wezterm/src/cli/mod.rs +++ b/wezterm/src/cli/mod.rs @@ -148,7 +148,7 @@ Outputs the pane-id for the newly created pane on success" RenameWorkspace(rename_workspace::RenameWorkspace), } -async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow::Result<()> { +async fn run_cli_async(opts: &crate::Opt, cli: CliCommand) -> anyhow::Result<()> { let mut ui = mux::connui::ConnectionUI::new_headless(); let initial = true; @@ -169,8 +169,8 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow: CliSubCommand::SplitPane(cmd) => cmd.run(client).await, CliSubCommand::SendText(cmd) => cmd.run(client).await, CliSubCommand::GetText(cmd) => cmd.run(client).await, - CliSubCommand::SpawnCommand(cmd) => cmd.run(client, &config).await, - CliSubCommand::Proxy(cmd) => cmd.run(client, &config).await, + CliSubCommand::SpawnCommand(cmd) => cmd.run(client, &crate::init_config(opts)?).await, + CliSubCommand::Proxy(cmd) => cmd.run(client, &crate::init_config(opts)?).await, CliSubCommand::TlsCreds(cmd) => cmd.run(client).await, CliSubCommand::ActivatePaneDirection(cmd) => cmd.run(client).await, CliSubCommand::KillPane(cmd) => cmd.run(client).await, @@ -182,9 +182,9 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow: } } -pub fn run_cli(config: config::ConfigHandle, cli: CliCommand) -> anyhow::Result<()> { +pub fn run_cli(opts: &crate::Opt, cli: CliCommand) -> anyhow::Result<()> { let executor = promise::spawn::ScopedExecutor::new(); - match promise::spawn::block_on(executor.run(async move { run_cli_async(config, cli).await })) { + match promise::spawn::block_on(executor.run(async move { run_cli_async(opts, cli).await })) { Ok(_) => Ok(()), Err(err) => crate::terminate_with_error(err), } diff --git a/wezterm/src/main.rs b/wezterm/src/main.rs index 27c729254..3f3746540 100644 --- a/wezterm/src/main.rs +++ b/wezterm/src/main.rs @@ -19,7 +19,7 @@ mod cli; about = "Wez's Terminal Emulator\nhttp://github.com/wez/wezterm", version = wezterm_version() )] -struct Opt { +pub struct Opt { /// Skip loading wezterm.lua #[arg(long, short = 'n')] skip_config: bool, @@ -275,7 +275,7 @@ fn run() -> anyhow::Result<()> { | SubCommand::Connect(_) => delegate_to_gui(saver), SubCommand::ImageCat(cmd) => cmd.run(), SubCommand::SetCwd(cmd) => cmd.run(), - SubCommand::Cli(cli) => cli::run_cli(init_config(&opts)?, cli), + SubCommand::Cli(cli) => cli::run_cli(&opts, cli), SubCommand::Record(cmd) => cmd.run(init_config(&opts)?), SubCommand::Replay(cmd) => cmd.run(), SubCommand::ShellCompletion { shell } => {