Skip to content

Commit 387747c

Browse files
committed
init stats
1 parent 9578695 commit 387747c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

internal/cmd/root.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var (
3535
workingBranchSuffix string
3636
dependabot bool
3737
caseSensitiveLabels bool
38+
noColor bool
39+
noStats bool
3840
)
3941

4042
// NewRootCmd creates the root command for the gh-combine CLI
@@ -96,6 +98,8 @@ func NewRootCmd() *cobra.Command {
9698
# Additional options
9799
gh combine owner/repo --autoclose # Close source PRs when combined PR is merged
98100
gh combine owner/repo --base-branch main # Use a different base branch for the combined PR
101+
gh combine owner/repo --no-color # Disable color output
102+
gh combine owner/repo --no-stats # Disable stats summary display
99103
gh combine owner/repo --combine-branch-name combined-prs # Use a different name for the combined PR branch
100104
gh combine owner/repo --working-branch-suffix -working # Use a different suffix for the working branch
101105
gh combine owner/repo --update-branch # Update the branch of the combined PR`,
@@ -127,6 +131,8 @@ func NewRootCmd() *cobra.Command {
127131
rootCmd.Flags().IntVar(&minimum, "minimum", 2, "Minimum number of PRs to combine")
128132
rootCmd.Flags().StringVar(&defaultOwner, "owner", "", "Default owner for repositories (if not specified in repo name or missing from file inputs)")
129133
rootCmd.Flags().BoolVar(&caseSensitiveLabels, "case-sensitive-labels", false, "Use case-sensitive label matching")
134+
rootCmd.Flags().BoolVar(&noColor, "no-color", false, "Disable color output")
135+
rootCmd.Flags().BoolVar(&noStats, "no-stats", false, "Disable stats summary display")
130136

131137
// Add deprecated flags for backward compatibility
132138
// rootCmd.Flags().IntVar(&minimum, "min-combine", 2, "Minimum number of PRs to combine (deprecated, use --minimum)")
@@ -177,6 +183,10 @@ func runCombine(cmd *cobra.Command, args []string) error {
177183
return fmt.Errorf("command execution failed: %w", err)
178184
}
179185

186+
if !noStats {
187+
displayStatsSummary()
188+
}
189+
180190
return nil
181191
}
182192

@@ -343,3 +353,27 @@ func fetchOpenPullRequests(ctx context.Context, client *api.RESTClient, repo git
343353

344354
return allPulls, nil
345355
}
356+
357+
func displayStatsSummary() {
358+
// Example implementation of stats summary display
359+
if noColor {
360+
fmt.Println("Stats Summary (Color Disabled):")
361+
} else {
362+
fmt.Println("\033[1;34mStats Summary:\033[0m") // Blue color for title
363+
}
364+
365+
// Example stats data
366+
fmt.Println("Repositories Processed: 5")
367+
fmt.Println("PRs Combined: 10")
368+
fmt.Println("PRs Skipped (Merge Conflicts): 2")
369+
fmt.Println("PRs Skipped (Criteria Not Met): 3")
370+
fmt.Println("Execution Time: 1m30s")
371+
372+
if !noColor {
373+
fmt.Println("\033[1;32mLinks to Combined PRs:\033[0m") // Green color for links section
374+
} else {
375+
fmt.Println("Links to Combined PRs:")
376+
}
377+
fmt.Println("- https://github.com/owner/repo1/pull/123")
378+
fmt.Println("- https://github.com/owner/repo2/pull/456")
379+
}

0 commit comments

Comments
 (0)