Skip to content

Commit 3ac5ee3

Browse files
committed
fix: completions command manifest error
1 parent 591efa3 commit 3ac5ee3

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/main.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,22 @@ fn get_base_dir() -> PathBuf {
6868
}
6969

7070
fn main() {
71+
let cli = Cli::parse();
72+
73+
// Handle shell completions first.
74+
if let Some(Commands::Completions { shell }) = cli.command {
75+
use clap_complete::generate;
76+
use std::io;
77+
let mut cmd = Cli::command();
78+
generate(shell, &mut cmd, "flatplay", &mut io::stdout());
79+
return;
80+
}
81+
7182
let base_dir = get_base_dir();
7283
let base_dir_for_panic_hook = base_dir.clone();
7384
let mut state = State::load(base_dir).unwrap();
7485

75-
let cli = Cli::parse();
76-
86+
// Handle the "stop" command early.
7787
if let Some(Commands::Stop) = cli.command {
7888
handle_command!(kill_process_group(&mut state));
7989
return;
@@ -128,15 +138,12 @@ fn main() {
128138
};
129139

130140
match &cli.command {
131-
Some(Commands::Completions { shell }) => {
132-
use clap_complete::generate;
133-
use std::io;
134-
let mut cmd = Cli::command();
135-
generate(*shell, &mut cmd, "flatplay", &mut io::stdout());
136-
}
141+
// Handled earlier.
142+
Some(Commands::Completions { shell: _ }) => {}
143+
Some(Commands::Stop) => {}
144+
137145
Some(Commands::Build) => handle_command!(flatpak_manager.build()),
138146
Some(Commands::BuildAndRun) => handle_command!(flatpak_manager.build_and_run()),
139-
Some(Commands::Stop) => handle_command!(flatpak_manager.stop()),
140147
Some(Commands::Run) => handle_command!(flatpak_manager.run()),
141148
Some(Commands::UpdateDependencies) => {
142149
handle_command!(flatpak_manager.update_dependencies())

0 commit comments

Comments
 (0)