diff options
author | a-kenji <aks.kenji@protonmail.com> | 2022-06-10 20:03:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-10 20:03:13 +0200 |
commit | 67d2673cae60954e8287c2a1f58a21a56e066afb (patch) | |
tree | 5c469728075ea59723951c6b535253e30ebeaec4 /src | |
parent | bcaa6b82c5c3eec824110387b396aacae3a52e21 (diff) |
add(style): add trailing comma in match blocks (#1483)
This makes it easier to distinguish from normal blocks
Diffstat (limited to 'src')
-rw-r--r-- | src/commands.rs | 32 | ||||
-rw-r--r-- | src/sessions.rs | 26 | ||||
-rw-r--r-- | src/tests/e2e/remote_runner.rs | 6 |
3 files changed, 32 insertions, 32 deletions
diff --git a/src/commands.rs b/src/commands.rs index a2311dc77..f92ba8b43 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -27,7 +27,7 @@ pub(crate) fn kill_all_sessions(yes: bool) { Ok(sessions) if sessions.is_empty() => { eprintln!("No active zellij sessions found."); process::exit(1); - } + }, Ok(sessions) => { if !yes { println!("WARNING: this action will kill all sessions."); @@ -44,11 +44,11 @@ pub(crate) fn kill_all_sessions(yes: bool) { kill_session_impl(session); } process::exit(0); - } + }, Err(e) => { eprintln!("Error occurred: {:?}", e); process::exit(1); - } + }, } } @@ -58,11 +58,11 @@ pub(crate) fn kill_session(target_session: &Option<String>) { assert_session(target_session); kill_session_impl(target_session); process::exit(0); - } + }, None => { println!("Please specify the session name to kill."); process::exit(1); - } + }, } } @@ -74,7 +74,7 @@ fn get_os_input<OsInputOutput>( Err(e) => { eprintln!("failed to open terminal:\n{}", e); process::exit(1); - } + }, } } @@ -108,7 +108,7 @@ fn find_indexed_session( ); print_sessions_with_index(sessions); process::exit(1); - } + }, } } @@ -122,12 +122,12 @@ fn attach_with_session_index(config_options: Options, index: usize, create: bool eprintln!("No active zellij sessions found."); process::exit(1); } - } + }, Ok(sessions) => find_indexed_session(sessions, config_options, index, create), Err(e) => { eprintln!("Error occurred: {:?}", e); process::exit(1); - } + }, } } @@ -143,11 +143,11 @@ fn attach_with_session_name( } else { ClientInfo::Attach(session_name.unwrap(), config_options) } - } + }, Some(prefix) => match match_session_name(prefix).unwrap() { SessionNameMatch::UniquePrefix(s) | SessionNameMatch::Exact(s) => { ClientInfo::Attach(s, config_options) - } + }, SessionNameMatch::AmbiguousPrefix(sessions) => { println!( "Ambiguous selection: multiple sessions names start with '{}':", @@ -155,24 +155,24 @@ fn attach_with_session_name( ); print_sessions(sessions); process::exit(1); - } + }, SessionNameMatch::None => { eprintln!("No session with the name '{}' found!", prefix); process::exit(1); - } + }, }, None => match get_active_session() { ActiveSession::None if create => create_new_client(), ActiveSession::None => { eprintln!("No active zellij sessions found."); process::exit(1); - } + }, ActiveSession::One(session_name) => ClientInfo::Attach(session_name, config_options), ActiveSession::Many => { println!("Please specify the session to attach to, either by using the full name or a unique prefix.\nThe following sessions are active:"); print_sessions(get_sessions().unwrap()); process::exit(1); - } + }, }, } } @@ -183,7 +183,7 @@ pub(crate) fn start_client(opts: CliArgs) { Err(e) => { eprintln!("{}", e); process::exit(1); - } + }, }; let os_input = get_os_input(get_client_os_input); diff --git a/src/sessions.rs b/src/sessions.rs index f7644b63d..38f783977 100644 --- a/src/sessions.rs +++ b/src/sessions.rs @@ -21,7 +21,7 @@ pub(crate) fn get_sessions() -> Result<Vec<String>, io::ErrorKind> { } }); Ok(sessions) - } + }, Err(err) if io::ErrorKind::NotFound != err.kind() => Err(err.kind()), Err(_) => Ok(Vec::with_capacity(0)), } @@ -43,7 +43,7 @@ pub(crate) fn get_sessions_sorted_by_mtime() -> anyhow::Result<Vec<String>> { let sessions = sessions_with_mtime.iter().map(|x| x.0.clone()).collect(); Ok(sessions) - } + }, Err(err) if io::ErrorKind::NotFound != err.kind() => Err(err.into()), Err(_) => Ok(Vec::with_capacity(0)), } @@ -59,14 +59,14 @@ fn assert_socket(name: &str) -> bool { match receiver.recv() { Some((instruction, _)) => { matches!(instruction, ServerToClientMsg::Connected) - } + }, None => false, } - } + }, Err(e) if e.kind() == io::ErrorKind::ConnectionRefused => { drop(fs::remove_file(path)); false - } + }, Err(_) => false, } } @@ -109,7 +109,7 @@ pub(crate) fn get_active_session() -> ActiveSession { Err(e) => { eprintln!("Error occurred: {:?}", e); process::exit(1); - } + }, } } @@ -118,11 +118,11 @@ pub(crate) fn kill_session(name: &str) { match LocalSocketStream::connect(path) { Ok(stream) => { IpcSenderWithContext::new(stream).send(ClientToServerMsg::KillSession); - } + }, Err(e) => { eprintln!("Error occurred: {:?}", e); process::exit(1); - } + }, }; } @@ -131,15 +131,15 @@ pub(crate) fn list_sessions() { Ok(sessions) if !sessions.is_empty() => { print_sessions(sessions); 0 - } + }, Ok(_) => { eprintln!("No active zellij sessions found."); 1 - } + }, Err(e) => { eprintln!("Error occurred: {:?}", e); 1 - } + }, }; process::exit(exit_code); } @@ -192,10 +192,10 @@ pub(crate) fn assert_session(name: &str) { println!(" help: Did you mean `{}`?", sugg); } } - } + }, Err(e) => { eprintln!("Error occurred: {:?}", e); - } + }, }; process::exit(1); } diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs index ad15de228..eb9b33152 100644 --- a/src/tests/e2e/remote_runner.rs +++ b/src/tests/e2e/remote_runner.rs @@ -201,7 +201,7 @@ fn read_from_channel( terminal_output.cursor_coordinates().unwrap_or((0, 0)); *last_snapshot = current_snapshot; should_sleep = true; - } + }, Ok(count) => { for byte in buf.iter().take(count) { vte_parser.advance(&mut terminal_output.grid, *byte); @@ -212,7 +212,7 @@ fn read_from_channel( terminal_output.grid.cursor_coordinates().unwrap_or((0, 0)); *last_snapshot = current_snapshot; should_sleep = true; - } + }, Err(e) => { if e.kind() == std::io::ErrorKind::WouldBlock { let current_snapshot = take_snapshot(&mut terminal_output); @@ -226,7 +226,7 @@ fn read_from_channel( } else { break; } - } + }, } } } |