1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-30 06:03:39 +03:00

cli: defer parsing config in most cases

refs: https://github.com/mrjones2014/smart-splits.nvim/discussions/52
refs: #3402
This commit is contained in:
Wez Furlong 2023-04-04 14:43:16 -07:00
parent 4be2b9dbeb
commit 084e656996
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
2 changed files with 7 additions and 7 deletions

View File

@ -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),
}

View File

@ -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 } => {