Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 0d8eec1

Browse files
committed
Group commands in help output
1 parent 2193cad commit 0d8eec1

File tree

1 file changed

+48
-28
lines changed

1 file changed

+48
-28
lines changed

lib/git/pkgs/cli.rb

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,39 @@
55
module Git
66
module Pkgs
77
class CLI
8-
COMMANDS = %w[init update hooks info list tree history search where why blame stale stats diff branch show log upgrade schema diff-driver].freeze
8+
COMMAND_GROUPS = {
9+
"Setup" => {
10+
"init" => "Initialize the package database for this repository",
11+
"update" => "Update the database with new commits",
12+
"hooks" => "Manage git hooks for auto-updating",
13+
"upgrade" => "Upgrade database after git-pkgs update",
14+
"info" => "Show database size and row counts",
15+
"branch" => "Manage tracked branches",
16+
"schema" => "Show database schema",
17+
"diff-driver" => "Install git textconv driver for lockfile diffs"
18+
},
19+
"Query" => {
20+
"list" => "List dependencies at a commit",
21+
"tree" => "Show dependency tree grouped by type",
22+
"search" => "Find a dependency across all history",
23+
"where" => "Show where a package appears in manifest files",
24+
"why" => "Explain why a dependency exists"
25+
},
26+
"History" => {
27+
"history" => "Show the history of a package",
28+
"blame" => "Show who added each dependency",
29+
"log" => "List commits with dependency changes",
30+
"show" => "Show dependency changes in a commit",
31+
"diff" => "Show dependency changes between commits"
32+
},
33+
"Analysis" => {
34+
"stats" => "Show dependency statistics",
35+
"stale" => "Show dependencies that haven't been updated"
36+
}
37+
}.freeze
38+
39+
COMMANDS = COMMAND_GROUPS.values.flat_map(&:keys).freeze
40+
COMMAND_DESCRIPTIONS = COMMAND_GROUPS.values.reduce({}, :merge).freeze
941
ALIASES = { "praise" => "blame", "outdated" => "stale" }.freeze
1042

1143
def self.run(args)
@@ -46,36 +78,24 @@ def run_command(command)
4678
end
4779

4880
def print_help
49-
puts <<~HELP
50-
Usage: git pkgs <command> [options]
81+
puts "Usage: git pkgs <command> [options]"
82+
puts
5183

52-
Commands:
53-
init Initialize the package database for this repository
54-
update Update the database with new commits
55-
hooks Manage git hooks for auto-updating
56-
info Show database size and row counts
57-
branch Manage tracked branches
58-
list List dependencies at a commit
59-
tree Show dependency tree grouped by type
60-
history Show the history of a package
61-
search Find a dependency across all history
62-
where Show where a package appears in manifest files
63-
why Explain why a dependency exists
64-
blame Show who added each dependency
65-
stale Show dependencies that haven't been updated
66-
stats Show dependency statistics
67-
diff Show dependency changes between commits
68-
show Show dependency changes in a commit
69-
log List commits with dependency changes
70-
upgrade Upgrade database after git-pkgs update
71-
schema Show database schema
84+
max_cmd_len = COMMANDS.map(&:length).max
7285

73-
Options:
74-
-h, --help Show this help message
75-
-v, --version Show version
86+
COMMAND_GROUPS.each do |group, commands|
87+
puts "#{group}:"
88+
commands.each do |cmd, desc|
89+
puts " #{cmd.ljust(max_cmd_len)} #{desc}"
90+
end
91+
puts
92+
end
7693

77-
Run 'git pkgs <command> --help' for command-specific options.
78-
HELP
94+
puts "Options:"
95+
puts " -h, --help Show this help message"
96+
puts " -v, --version Show version"
97+
puts
98+
puts "Run 'git pkgs <command> -h' for command-specific options."
7999
end
80100
end
81101
end

0 commit comments

Comments
 (0)