diff options
| author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-19 18:09:22 +0530 |
|---|---|---|
| committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-22 22:19:50 +0530 |
| commit | d6fc7b04d14e8eeb5157cace639cc1d157766987 (patch) | |
| tree | 3c8ff910ad3864c091340de5ef55236e59d17ac7 /zellij-utils | |
| parent | Merge pull request #530 from a-kenji/action-doc (diff) | |
| download | sl0ppij-d6fc7b04d14e8eeb5157cace639cc1d157766987.tar.gz sl0ppij-d6fc7b04d14e8eeb5157cace639cc1d157766987.tar.xz sl0ppij-d6fc7b04d14e8eeb5157cace639cc1d157766987.zip | |
add attach and list sessions subcommand to CliArgs
Diffstat (limited to 'zellij-utils')
| -rw-r--r-- | zellij-utils/src/cli.rs | 29 | ||||
| -rw-r--r-- | zellij-utils/src/input/config.rs | 6 | ||||
| -rw-r--r-- | zellij-utils/src/input/options.rs | 6 |
3 files changed, 32 insertions, 9 deletions
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs index 4b2fdbbf..87f929c7 100644 --- a/zellij-utils/src/cli.rs +++ b/zellij-utils/src/cli.rs @@ -17,7 +17,7 @@ pub struct CliArgs { pub data_dir: Option<PathBuf>, /// Run server listening at the specified socket path - #[structopt(long, parse(from_os_str))] + #[structopt(long, parse(from_os_str), hidden = true)] pub server: Option<PathBuf>, /// Name of a layout file in the layout directory @@ -37,14 +37,14 @@ pub struct CliArgs { pub config_dir: Option<PathBuf>, #[structopt(subcommand)] - pub option: Option<ConfigCli>, + pub command: Option<Command>, #[structopt(short, long)] pub debug: bool, } #[derive(Debug, StructOpt, Clone, Serialize, Deserialize)] -pub enum ConfigCli { +pub enum Command { /// Change the behaviour of zellij #[structopt(name = "options")] Options(Options), @@ -52,4 +52,27 @@ pub enum ConfigCli { /// Setup zellij and check its configuration #[structopt(name = "setup")] Setup(Setup), + + /// Explore existing zellij sessions + #[structopt(flatten)] + Sessions(Sessions), +} + +#[derive(Debug, StructOpt, Clone, Serialize, Deserialize)] +pub enum Sessions { + /// List active sessions + #[structopt(alias = "ls")] + ListSessions, + + /// Attach to session + #[structopt(alias = "a")] + Attach { + /// Name of the session to attach to. + session_name: String, + + /// Force attach- session will detach from the other + /// zellij client (if any) and attach to this. + #[structopt(long, short)] + force: bool, + }, } diff --git a/zellij-utils/src/input/config.rs b/zellij-utils/src/input/config.rs index a0341689..c4cf0cd7 100644 --- a/zellij-utils/src/input/config.rs +++ b/zellij-utils/src/input/config.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use super::keybinds::{Keybinds, KeybindsFromYaml}; use super::options::Options; -use crate::cli::{CliArgs, ConfigCli}; +use crate::cli::{CliArgs, Command}; use crate::setup; use serde::{Deserialize, Serialize}; @@ -60,7 +60,7 @@ impl TryFrom<&CliArgs> for Config { return Config::new(&path); } - if let Some(ConfigCli::Setup(setup)) = opts.option.clone() { + if let Some(Command::Setup(ref setup)) = opts.command { if setup.clean { return Config::from_default_assets(); } @@ -179,7 +179,7 @@ mod config_test { fn try_from_cli_args_with_option_clean() { use crate::setup::Setup; let mut opts = CliArgs::default(); - opts.option = Some(ConfigCli::Setup(Setup { + opts.command = Some(Command::Setup(Setup { clean: true, ..Setup::default() })); diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index 33625b65..f9724c20 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -1,5 +1,5 @@ //! Handles cli and configuration options -use crate::cli::ConfigCli; +use crate::cli::Command; use serde::{Deserialize, Serialize}; use structopt::StructOpt; @@ -35,8 +35,8 @@ impl Options { Options { simplified_ui } } - pub fn from_cli(&self, other: Option<ConfigCli>) -> Options { - if let Some(ConfigCli::Options(options)) = other { + pub fn from_cli(&self, other: Option<Command>) -> Options { + if let Some(Command::Options(options)) = other { Options::merge(&self, options) } else { self.to_owned() |
