Skip to content

Commit f8d6c9d

Browse files
committed
(startup) start with stash view when cli command indicates it
1 parent 2677169 commit f8d6c9d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/app.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{
22
accessors,
3+
args::StartMode,
34
cmdbar::CommandBar,
45
components::{
56
command_pump, event_pump, AppOption, BlameFileComponent,
@@ -119,6 +120,7 @@ impl App {
119120
input: Input,
120121
theme: Theme,
121122
key_config: KeyConfig,
123+
start_mode: &Option<StartMode>,
122124
) -> Result<Self> {
123125
log::trace!("open repo at: {:?}", &repo);
124126

@@ -130,7 +132,11 @@ impl App {
130132
let key_config = Rc::new(key_config);
131133
let options = Options::new(repo.clone());
132134

133-
let tab = options.borrow().current_tab();
135+
let tab = if matches!(start_mode, Some(StartMode::Stash)) {
136+
4
137+
} else {
138+
options.borrow().current_tab()
139+
};
134140

135141
let mut app = Self {
136142
input,

src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ mod watcher;
5050
use crate::{app::App, args::process_cmdline};
5151
use anyhow::{bail, Result};
5252
use app::QuitState;
53+
use args::StartMode;
5354
use asyncgit::{
5455
sync::{utils::repo_work_dir, RepoPath},
5556
AsyncGitNotification,
@@ -146,6 +147,7 @@ fn main() -> Result<()> {
146147
let mut terminal = start_terminal(io::stdout())?;
147148
let mut repo_path = cliargs.repo_path;
148149
let input = Input::new();
150+
let mut start_mode = cliargs.start_mode;
149151

150152
let updater = if cliargs.notify_watcher {
151153
Updater::NotifyWatcher
@@ -159,6 +161,7 @@ fn main() -> Result<()> {
159161
repo_path.clone(),
160162
theme,
161163
key_config.clone(),
164+
&start_mode.take(), // so start_mode is passed only once at start
162165
&input,
163166
updater,
164167
&mut terminal,
@@ -175,11 +178,13 @@ fn main() -> Result<()> {
175178
Ok(())
176179
}
177180

181+
#[allow(clippy::too_many_arguments)]
178182
fn run_app(
179183
app_start: Instant,
180184
repo: RepoPath,
181185
theme: Theme,
182186
key_config: KeyConfig,
187+
start_mode: &Option<StartMode>,
183188
input: &Input,
184189
updater: Updater,
185190
terminal: &mut Terminal<CrosstermBackend<io::Stdout>>,
@@ -208,6 +213,7 @@ fn run_app(
208213
input.clone(),
209214
theme,
210215
key_config,
216+
start_mode,
211217
)?;
212218

213219
let mut spinner = Spinner::default();

0 commit comments

Comments
 (0)