From 7ed66d3e785824b7a1ee363701931c232bde8b30 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Sat, 25 Jun 2022 21:48:00 +0200 Subject: add(feature): `unstable` (#1542) Add a feature `unstable`, which is intended to communicate the same intent. Gate: Send actions from cli with the `unstable` feature. --- Cargo.toml | 1 + src/commands.rs | 10 ++++++++-- src/main.rs | 11 ++++++++--- zellij-client/Cargo.toml | 2 +- zellij-utils/Cargo.toml | 1 + zellij-utils/src/cli.rs | 1 + 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c8ea31bf9..36b5d9822 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,3 +68,4 @@ pkg-fmt = "tgz" [features] disable_automatic_asset_installation = [ "zellij-utils/disable_automatic_asset_installation" ] +unstable = [ "zellij-client/unstable", "zellij-utils/unstable" ] diff --git a/src/commands.rs b/src/commands.rs index ae3d4f848..4eaea23b0 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -6,14 +6,13 @@ use crate::sessions::{ session_exists, ActiveSession, SessionNameMatch, }; use dialoguer::Confirm; -use miette::{IntoDiagnostic, Result}; +use miette::Result; use std::path::PathBuf; use std::process; use zellij_client::start_client as start_client_impl; use zellij_client::{os_input_output::get_client_os_input, ClientInfo}; use zellij_server::os_input_output::get_server_os_input; use zellij_server::start_server as start_server_impl; -use zellij_utils::input::actions::ActionsFromYaml; use zellij_utils::input::options::Options; use zellij_utils::nix; use zellij_utils::{ @@ -22,6 +21,11 @@ use zellij_utils::{ setup::{get_default_data_dir, Setup}, }; +#[cfg(feature = "unstable")] +use miette::IntoDiagnostic; +#[cfg(feature = "unstable")] +use zellij_utils::input::actions::ActionsFromYaml; + pub(crate) use crate::sessions::list_sessions; pub(crate) fn kill_all_sessions(yes: bool) { @@ -115,6 +119,7 @@ fn find_indexed_session( } /// Send a vec of `[Action]` to a currently running session. +#[cfg(feature = "unstable")] pub(crate) fn send_action_to_session(opts: zellij_utils::cli::CliArgs) { match get_active_session() { ActiveSession::None => { @@ -138,6 +143,7 @@ pub(crate) fn send_action_to_session(opts: zellij_utils::cli::CliArgs) { }; } +#[cfg(feature = "unstable")] fn attach_with_fake_client(opts: zellij_utils::cli::CliArgs, name: &str) { if let Some(zellij_utils::cli::Command::Sessions(zellij_utils::cli::Sessions::Action { action: Some(action), diff --git a/src/main.rs b/src/main.rs index 6e5cd9e95..ca05dbf10 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,11 +14,16 @@ fn main() { configure_logger(); let opts = CliArgs::parse(); + #[cfg(feature = "unstable")] + { + if let Some(Command::Sessions(Sessions::Action { .. })) = opts.command { + commands::send_action_to_session(opts); + std::process::exit(0); + } + } + if let Some(Command::Sessions(Sessions::ListSessions)) = opts.command { commands::list_sessions(); - } - if let Some(Command::Sessions(Sessions::Action { .. })) = opts.command { - commands::send_action_to_session(opts); } else if let Some(Command::Sessions(Sessions::KillAllSessions { yes })) = opts.command { commands::kill_all_sessions(yes); } else if let Some(Command::Sessions(Sessions::KillSession { ref target_session })) = diff --git a/zellij-client/Cargo.toml b/zellij-client/Cargo.toml index 3f1454d5b..1e937fe2b 100644 --- a/zellij-client/Cargo.toml +++ b/zellij-client/Cargo.toml @@ -18,4 +18,4 @@ log = "0.4.17" insta = "1.6.0" [features] - +unstable = [ ] diff --git a/zellij-utils/Cargo.toml b/zellij-utils/Cargo.toml index eb9c5f721..937857b56 100644 --- a/zellij-utils/Cargo.toml +++ b/zellij-utils/Cargo.toml @@ -50,3 +50,4 @@ features = ["unstable"] [features] disable_automatic_asset_installation = [] +unstable = [] diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs index 4b33fc6c2..c8a3ba1d0 100644 --- a/zellij-utils/src/cli.rs +++ b/zellij-utils/src/cli.rs @@ -110,5 +110,6 @@ pub enum Sessions { yes: bool, }, /// Send actions to a specific session + #[cfg(feature = "unstable")] Action { action: Option }, } -- cgit v1.2.3