summaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/cli.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2022-10-05 07:44:00 +0200
committerGitHub <noreply@github.com>2022-10-05 07:44:00 +0200
commit79bf6ab868cbdab1f9a3827c9b70198f54548b44 (patch)
tree2d6fc4c1d8a79ebd727a1a5f8b6406617dd0de55 /zellij-utils/src/cli.rs
parent917e9b2ff0f583183c0155060d243afd295770b9 (diff)
feat(config): switch to kdl (#1759)
* chore(config): default kdl keybindings config * tests * work * refactor(config): move stuff around * work * tab merge layout * work * work * layouts working * work * layout tests * work * work * feat(parsing): kdl layouts without config * refactor(kdl): move stuff around * work * tests(layout): add cases and fix bugs * work * fix(kdl): various bugs * chore(layouts): move all layouts to kdl * feat(kdl): shared keybidns * fix(layout): do not count fixed panes toward percentile * fix(keybinds): missing keybinds and actions * fix(config): adjust default tips * refactor(config): move stuff around * fix(tests): make e2e tests pass * fix(kdl): add verbose parsing errors * fix(kdl): focused tab * fix(layout): corret default_tab_template behavior * style(code): fix compile warnings * feat(cli): send actions through the cli * fix(cli): exit only when action is done * fix(cli): open embedded pane from floating pane * fix(cli): send actions to other sessions * feat(cli): command alias * feat(converter): convert old config * feat(converter): convert old layout and theme files * feat(kdl): pretty errors * feat(client): convert old YAML files on startup * fix: various bugs and styling issues * fix: e2e tests * fix(screen): propagate errors after merge * style(clippy): lower clippy level * fix(tests): own session_name variable * style(fmt): rustfmt * fix(cli): various action fixes * style(fmt): rustfmt * fix(themes): loading of theme files * style(fmt): rustfmt * fix(tests): theme fixtures * fix(layouts): better errors on unknown nodes * fix(kdl): clarify valid node terminator error * fix(e2e): adjust close tab test * fix(e2e): adjust close tab test again * style(code): cleanup some comments
Diffstat (limited to 'zellij-utils/src/cli.rs')
-rw-r--r--zellij-utils/src/cli.rs146
1 files changed, 144 insertions, 2 deletions
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs
index a947f9434..24616bd17 100644
--- a/zellij-utils/src/cli.rs
+++ b/zellij-utils/src/cli.rs
@@ -1,6 +1,8 @@
+use crate::data::InputMode;
use crate::setup::Setup;
use crate::{
consts::{ZELLIJ_CONFIG_DIR_ENV, ZELLIJ_CONFIG_FILE_ENV},
+ input::actions::{Direction, ResizeDirection},
input::options::CliOptions,
};
use clap::{Parser, Subcommand};
@@ -46,6 +48,15 @@ pub struct CliArgs {
pub debug: bool,
}
+impl CliArgs {
+ pub fn should_clean_config(&self) -> bool {
+ match &self.command {
+ Some(Command::Setup(ref setup)) => setup.clean,
+ _ => false,
+ }
+ }
+}
+
#[derive(Debug, Subcommand, Clone, Serialize, Deserialize)]
pub enum Command {
/// Change the behaviour of zellij
@@ -110,6 +121,137 @@ pub enum Sessions {
yes: bool,
},
/// Send actions to a specific session
- #[cfg(feature = "unstable")]
- Action { action: Option<String> },
+ #[clap(visible_alias = "ac")]
+ #[clap(subcommand)]
+ Action(CliAction),
+ /// Send actions to a specific session
+ #[clap(visible_alias = "c")]
+ Command {
+ command: Option<String>,
+ #[clap(short, long, value_parser, conflicts_with("floating"))]
+ direction: Option<Direction>,
+ #[clap(long, value_parser)]
+ cwd: Option<PathBuf>,
+ #[clap(short, long, value_parser, default_missing_value("true"))]
+ floating: Option<bool>,
+ },
+ /// Edit file with default $EDITOR / $VISUAL in a specific session
+ #[clap(visible_alias = "e")]
+ Edit {
+ file: PathBuf,
+ #[clap(short, long, value_parser)]
+ line_number: Option<usize>,
+ #[clap(short, long, value_parser, conflicts_with("floating"))]
+ direction: Option<Direction>,
+ #[clap(short, long, value_parser, default_missing_value("true"))]
+ floating: Option<bool>,
+ },
+ ConvertConfig {
+ old_config_file: PathBuf,
+ },
+ ConvertLayout {
+ old_layout_file: PathBuf,
+ },
+ ConvertTheme {
+ old_theme_file: PathBuf,
+ },
+}
+
+#[derive(Debug, Subcommand, Clone, Serialize, Deserialize)]
+pub enum CliAction {
+ /// Write bytes to the terminal.
+ Write { bytes: Vec<u8> },
+ /// Write characters to the terminal.
+ WriteChars { chars: String },
+ /// Resize the focused pane in the specified direction. [right|left|up|down|+|-]
+ Resize { resize_direction: ResizeDirection },
+ /// Change focus to the next pane
+ FocusNextPane,
+ /// Change focus to the previous pane
+ FocusPreviousPane,
+ /// Move the focused pane in the specified direction. [right|left|up|down]
+ MoveFocus { direction: Direction },
+ /// Move focus to the pane or tab (if on screen edge) in the specified direction
+ /// [right|left|up|down]
+ MoveFocusOrTab { direction: Direction },
+ /// Change the location of the focused pane in the specified direction
+ /// [right|left|up|down]
+ MovePane { direction: Direction },
+ /// Dumps the pane scrollback to a file
+ DumpScreen { path: PathBuf },
+ /// Open the pane scrollback in your default editor
+ EditScrollback,
+ /// Scroll up in the focused pane
+ ScrollUp,
+ /// Scroll down in focus pane.
+ ScrollDown,
+ /// Scroll down to bottom in focus pane.
+ ScrollToBottom,
+ /// Scroll up one page in focus pane.
+ PageScrollUp,
+ /// Scroll down one page in focus pane.
+ PageScrollDown,
+ /// Scroll up half page in focus pane.
+ HalfPageScrollUp,
+ /// Scroll down half page in focus pane.
+ HalfPageScrollDown,
+ /// Toggle between fullscreen focus pane and normal layout.
+ ToggleFullscreen,
+ /// Toggle frames around panes in the UI
+ TogglePaneFrames,
+ /// Toggle between sending text commands to all panes on the current tab and normal mode.
+ ToggleActiveSyncTab,
+ /// Open a new pane in the specified direction [right|left|up|down]
+ /// If no direction is specified, will try to use the biggest available space.
+ NewPane {
+ #[clap(short, long, value_parser, conflicts_with("floating"))]
+ direction: Option<Direction>,
+ #[clap(short, long, value_parser)]
+ command: Option<String>,
+ #[clap(long, value_parser)]
+ cwd: Option<PathBuf>,
+ #[clap(short, long, value_parser, default_missing_value("true"))]
+ floating: Option<bool>,
+ },
+ /// Open the specified file in a new zellij pane with your default EDITOR
+ Edit {
+ file: PathBuf,
+ #[clap(short, long, value_parser, conflicts_with("floating"))]
+ direction: Option<Direction>,
+ #[clap(short, long, value_parser)]
+ line_number: Option<usize>,
+ #[clap(short, long, value_parser, default_missing_value("true"))]
+ floating: Option<bool>,
+ },
+ /// Switch input mode of all connected clients [locked|pane|tab|resize|move|search|session]
+ SwitchMode { input_mode: InputMode },
+ /// Embed focused pane if floating or float focused pane if embedded
+ TogglePaneEmbedOrFloating,
+ /// Toggle the visibility of all fdirectionloating panes in the current Tab, open one if none exist
+ ToggleFloatingPanes,
+ /// Close the focused pane.
+ ClosePane,
+ /// Renames the focused pane
+ RenamePane { name: String },
+ /// Remove a previously set pane name
+ UndoRenamePane,
+ /// Go to the next tab.
+ GoToNextTab,
+ /// Go to the previous tab.
+ GoToPreviousTab,
+ /// Close the current tab.
+ CloseTab,
+ /// Go to tab with index [index]
+ GoToTab { index: u32 },
+ /// Renames the focused pane
+ RenameTab { name: String },
+ /// Remove a previously set tab name
+ UndoRenameTab,
+ /// Create a new tab, optionally with a specified tab layout and name
+ NewTab {
+ #[clap(short, long, value_parser)]
+ layout: Option<PathBuf>,
+ #[clap(short, long, value_parser)]
+ name: Option<String>,
+ },
}