diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-10-08 16:57:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-08 16:57:54 +0200 |
| commit | 203fbf7a491d1abc3cd9e05c1e39858af8395032 (patch) | |
| tree | 94c48ef5063b4b40d8ba5741320b8edd4c143955 /src/main.rs | |
| parent | docs(changelog): http fix (diff) | |
| download | sl0ppij-203fbf7a491d1abc3cd9e05c1e39858af8395032.tar.gz sl0ppij-203fbf7a491d1abc3cd9e05c1e39858af8395032.tar.xz sl0ppij-203fbf7a491d1abc3cd9e05c1e39858af8395032.zip | |
feat(cli): make --layout idempotent(-ish) (#3650)
* feat(cli): if inside a session, apply --layout to the session
* fix(screen): some focusing races when switching tab focus
* style(fmt): rustfmt
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index eacefc8a..18370985 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,8 +6,10 @@ mod tests; use zellij_utils::{ clap::Parser, cli::{CliAction, CliArgs, Command, Sessions}, + envs, input::config::Config, logging::*, + setup::Setup, }; fn main() { @@ -190,6 +192,30 @@ fn main() { commands::delete_session(target_session, force); } else if let Some(path) = opts.server { commands::start_server(path, opts.debug); + } else if let Some(layout) = &opts.layout { + if let Some(session_name) = opts + .session + .as_ref() + .cloned() + .or_else(|| envs::get_session_name().ok()) + { + let config = Config::try_from(&opts).ok(); + let options = Setup::from_cli_args(&opts).ok().map(|r| r.2); + let new_layout_cli_action = CliAction::NewTab { + layout: Some(layout.clone()), + layout_dir: options.as_ref().and_then(|o| o.layout_dir.clone()), + name: None, + cwd: options.as_ref().and_then(|o| o.default_cwd.clone()), + }; + commands::send_action_to_session(new_layout_cli_action, Some(session_name), config); + } else { + commands::start_client(opts); + } + } else if let Some(layout_for_new_session) = &opts.new_session_with_layout { + let mut opts = opts.clone(); + opts.new_session_with_layout = None; + opts.layout = Some(layout_for_new_session.clone()); + commands::start_client(opts); } else { commands::start_client(opts); } |
