diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2023-04-10 09:02:47 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2023-04-10 09:02:47 -0400 |
commit | cec35dbce007d37e5fb96b7d6997858d2914053b (patch) | |
tree | d5cbbe92bfb58f9d4031c46cf301b7c1dc40d8a9 | |
parent | 1edf9bb64033e45c1288d8cea7b6a6b45e6fa1d9 (diff) | |
parent | 1a7f79a66e5828cdb19910652677d03a12b66d6b (diff) |
Merge branch 'main' of github.com:kamiyaa/joshuto
-rw-r--r-- | docs/command_arguments.md | 3 | ||||
-rw-r--r-- | src/commands/tab_ops.rs | 7 | ||||
-rw-r--r-- | src/main.rs | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/docs/command_arguments.md b/docs/command_arguments.md index 21ec6a7..e296aba 100644 --- a/docs/command_arguments.md +++ b/docs/command_arguments.md @@ -11,6 +11,9 @@ Joshuto supports the following options from the command line: - `-h` `--help`: shows help menu + - `--change-directory`: sets the quit behavior to change directory instead of + noop when closing the last tab + - `--output-file <output-file>`: tells joshuto to output data to `<output-file>`. - This is usually used so programs can know how to behave after joshuto exits. - For example, cd into joshuto's current directory on quit diff --git a/src/commands/tab_ops.rs b/src/commands/tab_ops.rs index 1e33ed7..8650c73 100644 --- a/src/commands/tab_ops.rs +++ b/src/commands/tab_ops.rs @@ -159,7 +159,12 @@ pub fn new_tab(context: &mut AppContext, mode: &NewTabMode) -> JoshutoResult { pub fn close_tab(context: &mut AppContext) -> JoshutoResult { if context.tab_context_ref().len() <= 1 { - return quit_with_action(context, QuitAction::Noop); + let action = if context.args.change_directory { + QuitAction::OutputCurrentDirectory + } else { + QuitAction::Noop + }; + return quit_with_action(context, action); } let curr_tab_id = context.tab_context_ref().curr_tab_id(); let mut tab_index = context.tab_context_ref().index; diff --git a/src/main.rs b/src/main.rs index ab4be36..a2fe89b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,6 +80,8 @@ lazy_static! { pub struct Args { #[structopt(short = "v", long = "version")] version: bool, + #[structopt(long = "change-directory")] + change_directory: bool, #[structopt(long = "file-chooser")] file_chooser: bool, #[structopt(long = "output-file", parse(from_os_str))] |