summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-05-22 22:12:43 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-22 22:21:26 +0530
commit0621ba8f349a28d0f746f4c8349658025e5f64f5 (patch)
treebfe825e2987fdc3df35a12a380e1e0730757297e /src/main.rs
parent1162d40ea00aec38907c7079e53c62a02c2c5eda (diff)
Allow user to specify session name
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 5a6d5ed18..a91ce508c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,10 +2,10 @@ mod list_sessions;
#[cfg(test)]
mod tests;
-use list_sessions::{assert_session, list_sessions};
+use list_sessions::{assert_session, assert_session_ne, list_sessions};
use std::convert::TryFrom;
use std::process;
-use zellij_client::{os_input_output::get_client_os_input, start_client};
+use zellij_client::{os_input_output::get_client_os_input, start_client, ClientInfo};
use zellij_server::{os_input_output::get_server_os_input, start_server};
use zellij_utils::{
cli::{CliArgs, Command, Sessions},
@@ -61,10 +61,20 @@ pub fn main() {
Box::new(os_input),
opts,
config,
- Some((session_name, force)),
+ ClientInfo::Attach(session_name, force),
);
} else {
- start_client(Box::new(os_input), opts, config, None);
+ let session_name = opts
+ .session
+ .clone()
+ .unwrap_or_else(|| names::Generator::default().next().unwrap());
+ assert_session_ne(&session_name);
+ start_client(
+ Box::new(os_input),
+ opts,
+ config,
+ ClientInfo::New(session_name),
+ );
}
}
}