Skip to content

Commit 73cab33

Browse files
committed
updates
1 parent a2720c5 commit 73cab33

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/main.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,20 @@ const CREATE_BACKUP: bool = false;
2323

2424
// This is an important refactoring.
2525
#[derive(Parser)]
26-
#[command(author, version, about, arg_required_else_help = true)]
26+
#[command(author, version, about)]
2727
struct Args {
2828
#[arg(long, short, help = "Enable verbose output")]
2929
verbose: bool,
3030

3131
/// Subcommand to run.
3232
#[command(subcommand)]
33-
command: Commands,
33+
command: Option<Command>,
3434
}
3535

3636
#[derive(Subcommand)]
37-
enum Commands {
38-
/// Show the status of the git-stack tree in the current repo.
37+
enum Command {
38+
/// Show the status of the git-stack tree in the current repo. This is the default command when
39+
/// a command is omitted. (ie: `git stack` is the same as `git stack status`)
3940
Status,
4041
/// Restack your active branch and all branches in its related stack.
4142
Restack {
@@ -112,14 +113,18 @@ fn inner_main() -> Result<()> {
112113
tracing::debug!(run_version, current_branch, current_upstream);
113114

114115
match args.command {
115-
Commands::Checkout { branch_name } => {
116+
Some(Command::Checkout { branch_name }) => {
116117
state.checkout(&repo, current_branch, current_upstream, branch_name)
117118
}
118-
Commands::Restack { branch } => restack(state, &repo, run_version, branch, current_branch),
119-
Commands::Mount { parent_branch } => state.mount(&repo, &current_branch, parent_branch),
120-
Commands::Status => status(state, &repo, &current_branch),
121-
Commands::Delete { branch_name } => state.delete_branch(&repo, &branch_name),
122-
Commands::Diff { branch } => diff(state, &repo, &branch.unwrap_or(current_branch)),
119+
Some(Command::Restack { branch }) => {
120+
restack(state, &repo, run_version, branch, current_branch)
121+
}
122+
Some(Command::Mount { parent_branch }) => {
123+
state.mount(&repo, &current_branch, parent_branch)
124+
}
125+
Some(Command::Status) | None => status(state, &repo, &current_branch),
126+
Some(Command::Delete { branch_name }) => state.delete_branch(&repo, &branch_name),
127+
Some(Command::Diff { branch }) => diff(state, &repo, &branch.unwrap_or(current_branch)),
123128
}
124129
}
125130

0 commit comments

Comments
 (0)