Skip to content

Commit 625a3d1

Browse files
committed
fix!: normalize flags
BREAKING CHANGE: Some flags have changed. `restack`: `--only` is now `-c, --current`; `submit`: `--current-only` is now `-c, --current`, `--update-only` is now `-u, --update`, `--push-only` is now `-s, --skip-prs`, removed `-w` shorthand from `--web`. Other options have had shorthands added; see [README.md](https://github.com/boneskull/gh-stack/blob/main/README.md) for details.
1 parent b93be0b commit 625a3d1

11 files changed

Lines changed: 96 additions & 96 deletions

File tree

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ Display the branch tree showing the stack hierarchy, current branch, and associa
170170

171171
#### log Flags
172172

173-
| Flag | Description |
174-
| ------------- | ------------------------------------- |
175-
| `--all` | Show all branches |
176-
| `--porcelain` | Machine-readable tab-separated output |
173+
| Flag | Description |
174+
| ----------------- | ------------------------------------- |
175+
| `-a, --all` | Show all branches |
176+
| `-p, --porcelain` | Machine-readable tab-separated output |
177177

178178
#### Porcelain Format
179179

@@ -197,10 +197,10 @@ gh stack create <name>
197197

198198
#### create Flags
199199

200-
| Flag | Description |
201-
| --------------- | ----------------------------------------------- |
202-
| `-m, --message` | Commit message for staged changes |
203-
| `--empty` | Create branch without committing staged changes |
200+
| Flag | Description |
201+
| ----------------- | ----------------------------------------------- |
202+
| `-m, --message` | Commit message for staged changes |
203+
| `-C, --no-commit` | Create branch without committing staged changes |
204204

205205
### adopt
206206

@@ -216,9 +216,9 @@ gh stack adopt <parent>
216216

217217
#### adopt Flags
218218

219-
| Flag | Description |
220-
| ---------- | ----------------------------------------- |
221-
| `--branch` | Branch to adopt (default: current branch) |
219+
| Flag | Description |
220+
| -------------- | ----------------------------------------- |
221+
| `-b, --branch` | Branch to adopt (default: current branch) |
222222

223223
### orphan
224224

@@ -236,9 +236,9 @@ If no branch is specified, orphans the current branch.
236236

237237
#### orphan Flags
238238

239-
| Flag | Description |
240-
| --------- | --------------------------- |
241-
| `--force` | Also orphan all descendants |
239+
| Flag | Description |
240+
| ------------- | --------------------------- |
241+
| `-f, --force` | Also orphan all descendants |
242242

243243
### link
244244

@@ -276,15 +276,15 @@ If a rebase conflict occurs, resolve it and run `gh stack continue`.
276276

277277
#### submit Flags
278278

279-
| Flag | Description |
280-
| ---------------- | ------------------------------------------------------------------------ |
281-
| `--dry-run` | Show what would happen without doing it |
282-
| `--from [branch]` | Submit from this branch toward leaves (bare `--from` = current branch) |
283-
| `--current-only` | Only submit the current branch, not descendants |
284-
| `--update-only` | Only update existing PRs, don't create new ones |
285-
| `--push-only` | Skip PR creation/update, only restack and push |
286-
| `-y, --yes` | Skip interactive prompts; use auto-generated PR title/description |
287-
| `-w, --web` | Open created/updated PRs in web browser |
279+
| Flag | Description |
280+
| --------------------- | ---------------------------------------------------------------------- |
281+
| `-D, --dry-run` | Show what would happen without doing it |
282+
| `-f, --from [branch]` | Submit from this branch toward leaves (bare `--from` = current branch) |
283+
| `-c, --current` | Only submit the current branch, not descendants |
284+
| `-u, --update` | Only update existing PRs, don't create new ones |
285+
| `-s, --skip-prs` | Skip PR creation/update, only restack and push |
286+
| `-y, --yes` | Skip interactive prompts; use auto-generated PR title/description |
287+
| `--web` | Open created/updated PRs in web browser |
288288

289289
### restack
290290

@@ -296,11 +296,11 @@ If a rebase conflict occurs, resolve it and run `gh stack continue`.
296296

297297
#### restack Flags
298298

299-
| Flag | Description |
300-
| ------------- | -------------------------------------------------------- |
301-
| `--only` | Only restack current branch, not descendants |
302-
| `--dry-run` | Show what would be done |
303-
| `--worktrees` | Rebase branches checked out in linked worktrees in-place |
299+
| Flag | Description |
300+
| ----------------- | -------------------------------------------------------- |
301+
| `-c, --current` | Only restack current branch, not descendants |
302+
| `-D, --dry-run` | Show what would be done |
303+
| `-w, --worktrees` | Rebase branches checked out in linked worktrees in-place |
304304

305305
### continue
306306

@@ -322,11 +322,11 @@ This is the command to run when upstream changes have occurred (e.g., a PR in yo
322322

323323
#### sync Flags
324324

325-
| Flag | Description |
326-
| -------------- | -------------------------------------------------------- |
327-
| `--no-restack` | Skip restacking branches |
328-
| `--dry-run` | Show what would be done |
329-
| `--worktrees` | Rebase branches checked out in linked worktrees in-place |
325+
| Flag | Description |
326+
| ----------------- | -------------------------------------------------------- |
327+
| `--no-restack` | Skip restacking branches (might not work well!) |
328+
| `-D, --dry-run` | Show what would be done |
329+
| `-w, --worktrees` | Rebase branches checked out in linked worktrees in-place |
330330

331331
### undo
332332

@@ -346,10 +346,10 @@ Snapshots are stored in `.git/stack-undo/` and archived to `.git/stack-undo/done
346346
347347
#### undo Flags
348348

349-
| Flag | Description |
350-
| ----------- | -------------------------------------------- |
351-
| `--force` | Skip confirmation prompt |
352-
| `--dry-run` | Show what would be restored without doing it |
349+
| Flag | Description |
350+
| --------------- | -------------------------------------------- |
351+
| `-f, --force` | Skip confirmation prompt |
352+
| `-D, --dry-run` | Show what would be restored without doing it |
353353

354354
## Working with Git Worktrees
355355

cmd/adopt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ By default, adopts the current branch. Use --branch to specify a different branc
2626
var adoptBranchFlag string
2727

2828
func init() {
29-
adoptCmd.Flags().StringVar(&adoptBranchFlag, "branch", "", "branch to adopt (default: current branch)")
29+
adoptCmd.Flags().StringVarP(&adoptBranchFlag, "branch", "b", "", "branch to adopt (default: current branch)")
3030
rootCmd.AddCommand(adoptCmd)
3131
}
3232

cmd/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var (
2727

2828
func init() {
2929
createCmd.Flags().StringVarP(&createMessageFlag, "message", "m", "", "commit message for staged changes")
30-
createCmd.Flags().BoolVar(&createEmptyFlag, "empty", false, "create branch without committing staged changes")
30+
createCmd.Flags().BoolVarP(&createEmptyFlag, "no-commit", "C", false, "create branch without committing staged changes")
3131
rootCmd.AddCommand(createCmd)
3232
}
3333

@@ -77,7 +77,7 @@ func runCreate(cmd *cobra.Command, args []string) error {
7777

7878
if hasStaged && !createEmptyFlag {
7979
if createMessageFlag == "" {
80-
return errors.New("staged changes found but no commit message provided; use -m or --empty")
80+
return errors.New("staged changes found but no commit message provided; use -m or --no-commit")
8181
}
8282
}
8383

cmd/create_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ func TestCreateEmptyWithStagedChanges(t *testing.T) {
162162
os.WriteFile(f, []byte("content"), 0644)
163163
exec.Command("git", "-C", dir, "add", f).Run()
164164

165-
// Create branch WITHOUT committing (--empty behavior)
165+
// Create branch WITHOUT committing (--no-commit behavior)
166166
g.CreateAndCheckout("feature-empty")
167167
cfg.SetParent("feature-empty", trunk)
168-
// Don't commit - this simulates --empty flag
168+
// Don't commit - this simulates --no-commit flag
169169

170170
// Staged changes should still exist
171171
hasStaged, _ := g.HasStagedChanges()
172172
if !hasStaged {
173-
t.Error("expected staged changes to remain with --empty")
173+
t.Error("expected staged changes to remain with --no-commit")
174174
}
175175
}
176176

cmd/log.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ var (
2929
)
3030

3131
func init() {
32-
logCmd.Flags().BoolVar(&logAllFlag, "all", false, "show all branches")
33-
logCmd.Flags().BoolVar(&logPorcelainFlag, "porcelain", false, "machine-readable output")
32+
logCmd.Flags().BoolVarP(&logAllFlag, "all", "a", false, "show all branches")
33+
logCmd.Flags().BoolVarP(&logPorcelainFlag, "porcelain", "p", false, "machine-readable output")
3434
rootCmd.AddCommand(logCmd)
3535
}
3636

cmd/orphan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var orphanCmd = &cobra.Command{
2323
var orphanForceFlag bool
2424

2525
func init() {
26-
orphanCmd.Flags().BoolVar(&orphanForceFlag, "force", false, "also orphan all descendants")
26+
orphanCmd.Flags().BoolVarP(&orphanForceFlag, "force", "f", false, "also orphan all descendants")
2727
rootCmd.AddCommand(orphanCmd)
2828
}
2929

cmd/restack.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ var (
3333
)
3434

3535
func init() {
36-
restackCmd.Flags().BoolVar(&restackOnlyFlag, "only", false, "only restack current branch, not descendants")
37-
restackCmd.Flags().BoolVar(&restackDryRunFlag, "dry-run", false, "show what would be done")
38-
restackCmd.Flags().BoolVar(&restackWorktreesFlag, "worktrees", false, "rebase branches checked out in linked worktrees in-place")
36+
restackCmd.Flags().BoolVarP(&restackOnlyFlag, "current", "c", false, "only restack current branch, not descendants")
37+
restackCmd.Flags().BoolVarP(&restackDryRunFlag, "dry-run", "D", false, "show what would be done")
38+
restackCmd.Flags().BoolVarP(&restackWorktreesFlag, "worktrees", "w", false, "rebase branches checked out in linked worktrees in-place")
3939
rootCmd.AddCommand(restackCmd)
4040
}
4141

cmd/submit.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ type prDecision struct {
7373
// pushAnyway is true when action is prActionSkip but a descendant branch
7474
// will get a PR, so the branch must still exist on the remote as a base.
7575
pushAnyway bool
76-
// skipReason is set when action is prActionSkip ("update-only" or "user").
76+
// skipReason is set when action is prActionSkip ("update" or "user").
7777
skipReason string
7878
}
7979

8080
func init() {
81-
submitCmd.Flags().BoolVar(&submitDryRunFlag, "dry-run", false, "show what would be done without doing it")
82-
submitCmd.Flags().BoolVar(&submitCurrentOnlyFlag, "current-only", false, "only submit current branch, not descendants")
83-
submitCmd.Flags().BoolVar(&submitUpdateOnlyFlag, "update-only", false, "only update existing PRs, don't create new ones")
84-
submitCmd.Flags().BoolVar(&submitPushOnlyFlag, "push-only", false, "skip PR creation/update, only restack and push")
81+
submitCmd.Flags().BoolVarP(&submitDryRunFlag, "dry-run", "D", false, "show what would be done without doing it")
82+
submitCmd.Flags().BoolVarP(&submitCurrentOnlyFlag, "current", "c", false, "only submit current branch, not descendants")
83+
submitCmd.Flags().BoolVarP(&submitUpdateOnlyFlag, "update", "u", false, "only update existing PRs, don't create new ones")
84+
submitCmd.Flags().BoolVarP(&submitPushOnlyFlag, "skip-prs", "s", false, "skip PR creation/update, only restack and push")
8585
submitCmd.Flags().BoolVarP(&submitYesFlag, "yes", "y", false, "skip interactive prompts and use auto-generated title/description for PRs")
86-
submitCmd.Flags().BoolVarP(&submitWebFlag, "web", "w", false, "open created/updated PRs in web browser")
87-
submitCmd.Flags().StringVar(&submitFromFlag, "from", "", "submit from this branch toward leaves (default: entire stack; bare --from = current branch)")
86+
submitCmd.Flags().BoolVar(&submitWebFlag, "web", false, "open created/updated PRs in web browser")
87+
submitCmd.Flags().StringVarP(&submitFromFlag, "from", "f", "", "submit from this branch toward leaves (default: entire stack; bare --from = current branch)")
8888
submitCmd.Flags().Lookup("from").NoOptDefVal = "HEAD"
8989
rootCmd.AddCommand(submitCmd)
9090
}
@@ -94,13 +94,13 @@ func runSubmit(cmd *cobra.Command, args []string) error {
9494

9595
// Validate flag combinations
9696
if submitPushOnlyFlag && submitUpdateOnlyFlag {
97-
return errors.New("--push-only and --update-only cannot be used together: --push-only skips all PR operations")
97+
return errors.New("--skip-prs and --update cannot be used together: --skip-prs skips all PR operations")
9898
}
9999
if submitPushOnlyFlag && submitWebFlag {
100-
return errors.New("--push-only and --web cannot be used together: --push-only skips all PR operations")
100+
return errors.New("--skip-prs and --web cannot be used together: --skip-prs skips all PR operations")
101101
}
102102
if submitFromFlag != "" && submitCurrentOnlyFlag {
103-
return errors.New("--from and --current-only cannot be used together")
103+
return errors.New("--from and --current cannot be used together: --current limits the scope to the current branch")
104104
}
105105

106106
cwd, err := os.Getwd()
@@ -138,15 +138,15 @@ func runSubmit(cmd *cobra.Command, args []string) error {
138138

139139
// Collect branches to submit.
140140
//
141-
// --current-only: only the current branch (no descendants, no ancestors).
141+
// --current: only the current branch (no descendants, no ancestors).
142142
// --from (bare): current branch + descendants (old default behavior).
143143
// --from=<branch>: that branch + descendants.
144144
// Default: entire stack (all trunk descendants).
145145
var branches []*tree.Node
146146
if submitCurrentOnlyFlag {
147-
// --current-only: submit only the current checked-out branch
147+
// --current: submit only the current checked-out branch
148148
if currentBranch == trunk {
149-
return fmt.Errorf("cannot submit trunk branch %q; switch to a stack branch or remove --current-only", trunk)
149+
return fmt.Errorf("cannot submit trunk branch %q; switch to a stack branch or remove --current", trunk)
150150
}
151151
node := tree.FindNode(root, currentBranch)
152152
if node == nil {
@@ -280,7 +280,7 @@ func doSubmitPushAndPR(g *git.Git, cfg *config.Config, root *tree.Node, branches
280280
decisionByName[d.node.Name] = d
281281
}
282282

283-
// Phase 2: Push branches that will participate in PRs (or all if --push-only).
283+
// Phase 2: Push branches that will participate in PRs (or all if --skip-prs).
284284
fmt.Println(s.Bold("\n=== Phase 2: Push ==="))
285285
for _, b := range branches {
286286
var d *prDecision
@@ -306,7 +306,7 @@ func doSubmitPushAndPR(g *git.Git, cfg *config.Config, root *tree.Node, branches
306306

307307
if opts.PushOnly {
308308
fmt.Println(s.Bold("\n=== Phase 3: PRs ==="))
309-
fmt.Println(s.Muted("Skipped (--push-only)"))
309+
fmt.Println(s.Muted("Skipped (--skip-prs)"))
310310
return nil
311311
}
312312
return executePRDecisions(g, cfg, root, decisions, ghClient, opts, s)
@@ -326,7 +326,7 @@ func planPRDecisions(g *git.Git, cfg *config.Config, ghClient *github.Client, tr
326326
case existingPR > 0:
327327
out = append(out, &prDecision{node: b, parent: parent, action: prActionUpdate, prNum: existingPR})
328328
case updateOnly:
329-
out = append(out, &prDecision{node: b, parent: parent, action: prActionSkip, skipReason: "update-only"})
329+
out = append(out, &prDecision{node: b, parent: parent, action: prActionSkip, skipReason: "update"})
330330
case dryRun:
331331
out = append(out, planPRDecisionDryRun(g, b, parent, trunk, s))
332332
default:
@@ -447,14 +447,14 @@ func executePRDecisions(g *git.Git, cfg *config.Config, root *tree.Node, decisio
447447
switch d.action {
448448
case prActionSkip:
449449
if opts.DryRun {
450-
if d.skipReason == "update-only" {
451-
fmt.Printf("Skipping %s %s\n", s.Branch(b.Name), s.Muted("(no existing PR, --update-only)"))
450+
if d.skipReason == "update" {
451+
fmt.Printf("Skipping %s %s\n", s.Branch(b.Name), s.Muted("(no existing PR, --update)"))
452452
}
453453
continue
454454
}
455455
switch d.skipReason {
456-
case "update-only":
457-
fmt.Printf("Skipping %s %s\n", s.Branch(b.Name), s.Muted("(no existing PR, --update-only)"))
456+
case "update":
457+
fmt.Printf("Skipping %s %s\n", s.Branch(b.Name), s.Muted("(no existing PR, --update)"))
458458
case "user":
459459
fmt.Printf("Skipped PR for %s %s\n", s.Branch(b.Name), s.Muted("(skipped)"))
460460
}

cmd/sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ var (
3232

3333
func init() {
3434
syncCmd.Flags().BoolVar(&syncNoRestackFlag, "no-restack", false, "skip restacking branches")
35-
syncCmd.Flags().BoolVar(&syncDryRunFlag, "dry-run", false, "show what would be done")
36-
syncCmd.Flags().BoolVar(&syncWorktreesFlag, "worktrees", false, "rebase branches checked out in linked worktrees in-place")
35+
syncCmd.Flags().BoolVarP(&syncDryRunFlag, "dry-run", "D", false, "show what would be done")
36+
syncCmd.Flags().BoolVarP(&syncWorktreesFlag, "worktrees", "w", false, "rebase branches checked out in linked worktrees in-place")
3737
rootCmd.AddCommand(syncCmd)
3838
}
3939

cmd/undo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ var (
3636
)
3737

3838
func init() {
39-
rootCmd.AddCommand(undoCmd)
4039
undoCmd.Flags().BoolVarP(&undoForce, "force", "f", false, "Skip confirmation prompt")
41-
undoCmd.Flags().BoolVar(&undoDryRun, "dry-run", false, "Show what would be restored without making changes")
40+
undoCmd.Flags().BoolVarP(&undoDryRun, "dry-run", "D", false, "Show what would be restored without making changes")
41+
rootCmd.AddCommand(undoCmd)
4242
}
4343

4444
func runUndo(cmd *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)