zellij/zellij-utils/src/cli.rs
Jae-Heon Ji 09481aac19
feat: support themes directory (#1577)
* feat: add serde struct for theme file

* feat: update client to load the theme palette

* feat: merge themes in the setup phase

* chore: delete debug message in test

* feat: add theme_dir options

* fix: boxing large enum variant
2022-07-24 21:30:58 +09:00

115 lines
3.5 KiB
Rust

use crate::setup::Setup;
use crate::{
consts::{ZELLIJ_CONFIG_DIR_ENV, ZELLIJ_CONFIG_FILE_ENV},
input::options::CliOptions,
};
use clap::{Parser, Subcommand};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Parser, Default, Debug, Clone, Serialize, Deserialize)]
#[clap(version, name = "zellij")]
pub struct CliArgs {
/// Maximum panes on screen, caution: opening more panes will close old ones
#[clap(long, value_parser)]
pub max_panes: Option<usize>,
/// Change where zellij looks for plugins
#[clap(long, value_parser, overrides_with = "data_dir")]
pub data_dir: Option<PathBuf>,
/// Run server listening at the specified socket path
#[clap(long, value_parser, hide = true, overrides_with = "server")]
pub server: Option<PathBuf>,
/// Specify name of a new session
#[clap(long, short, overrides_with = "session", value_parser)]
pub session: Option<String>,
/// Name of a predefined layout inside the layout directory or the path to a layout file
#[clap(short, long, value_parser, overrides_with = "layout")]
pub layout: Option<PathBuf>,
/// Change where zellij looks for the configuration file
#[clap(short, long, overrides_with = "config", env = ZELLIJ_CONFIG_FILE_ENV, value_parser)]
pub config: Option<PathBuf>,
/// Change where zellij looks for the configuration directory
#[clap(long, overrides_with = "config_dir", env = ZELLIJ_CONFIG_DIR_ENV, value_parser)]
pub config_dir: Option<PathBuf>,
#[clap(subcommand)]
pub command: Option<Command>,
/// Specify emitting additional debug information
#[clap(short, long, value_parser)]
pub debug: bool,
}
#[derive(Debug, Subcommand, Clone, Serialize, Deserialize)]
pub enum Command {
/// Change the behaviour of zellij
#[clap(name = "options", value_parser)]
Options(CliOptions),
/// Setup zellij and check its configuration
#[clap(name = "setup", value_parser)]
Setup(Setup),
/// Explore existing zellij sessions
#[clap(flatten)]
Sessions(Sessions),
}
#[derive(Debug, Subcommand, Clone, Serialize, Deserialize)]
pub enum SessionCommand {
/// Change the behaviour of zellij
#[clap(name = "options")]
Options(CliOptions),
}
#[derive(Debug, Subcommand, Clone, Serialize, Deserialize)]
pub enum Sessions {
/// List active sessions
#[clap(visible_alias = "ls")]
ListSessions,
/// Attach to a session
#[clap(visible_alias = "a")]
Attach {
/// Name of the session to attach to.
#[clap(value_parser)]
session_name: Option<String>,
/// Create a session if one does not exist.
#[clap(short, long, value_parser)]
create: bool,
/// Number of the session index in the active sessions ordered creation date.
#[clap(long, value_parser)]
index: Option<usize>,
/// Change the behaviour of zellij
#[clap(subcommand, name = "options")]
options: Option<Box<SessionCommand>>,
},
/// Kill the specific session
#[clap(visible_alias = "k")]
KillSession {
/// Name of target session
#[clap(value_parser)]
target_session: Option<String>,
},
/// Kill all sessions
#[clap(visible_alias = "ka")]
KillAllSessions {
/// Automatic yes to prompts
#[clap(short, long, value_parser)]
yes: bool,
},
/// Send actions to a specific session
#[cfg(feature = "unstable")]
Action { action: Option<String> },
}