Skip to content

Commit 63c69ad

Browse files
authored
feat: organize CLI help commands into logical groups (#317)
* feat: organize help commands into logical groups Organize the sourcetool CLI help output into three logical command groups to improve discoverability and user experience: - Verification Commands: verifycommit, audit, status - Attestation & Evaluation Commands: checklevel, checklevelprov, checktag, prov - Configuration & Setup Commands: setup, auth, policy, createpolicy This uses Cobra's AddGroup feature to categorize commands by their primary function, making it easier for users to find the command they need. Assisted-by: Claude Code Signed-off-by: Ralph Bean <[email protected]> * refactor: separate policy commands into dedicated group Move createpolicy and policy commands from the Configuration & Setup group into their own Policy Commands group for better organization. The help output now shows four distinct command groups: - Verification Commands - Attestation & Evaluation Commands - Policy Commands - Configuration & Setup Commands This makes policy management commands more discoverable and logically separated from general configuration tasks. Assisted-by: Claude Code Signed-off-by: Ralph Bean <[email protected]> * docs: clarify audit command description Change audit command short description from "Audits the SLSA properties and controls of a repository" to "Verifies multiple commits in the branch history" to better describe what the command actually does. The word "multiple" is more accurate than "all" since the command can be limited with --depth and --ending-commit flags. Assisted-by: Claude Code Signed-off-by: Ralph Bean <[email protected]> * refactor: reorganize commands into Assessment group Rename "Attestation & Evaluation Commands" to "Assessment Commands" and move status from Verification to Assessment group. The new organization better reflects command behavior: Verification Commands (2): - audit: verifies multiple commits by reading existing VSAs - verifycommit: verifies single commit by reading existing VSA Assessment Commands (5): - status: assesses current repository controls - checklevel: assesses controls and creates VSA - checklevelprov: assesses with provenance creation - checktag: assesses tag operations - prov: creates provenance without policy evaluation "Assessment" encompasses both evaluation (status, checklevel) and attestation creation (prov), making it a better umbrella term than "Attestation & Evaluation". Assisted-by: Claude Code Signed-off-by: Ralph Bean <[email protected]> --------- Signed-off-by: Ralph Bean <[email protected]>
1 parent e7d44dd commit 63c69ad

File tree

12 files changed

+62
-23
lines changed

12 files changed

+62
-23
lines changed

internal/cmd/audit.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ func (ao *auditOpts) AddFlags(cmd *cobra.Command) {
8181
func addAudit(parentCmd *cobra.Command) {
8282
opts := &auditOpts{}
8383
auditCmd := &cobra.Command{
84-
Use: "audit",
85-
Short: "Audits the SLSA properties and controls of a repository",
84+
Use: "audit",
85+
GroupID: "verification",
86+
Short: "Verifies multiple commits in the branch history",
8687
Long: `Checks the revisions on the specified branch within the repository.
8788
8889
Revisions 'pass' an audit if they have:

internal/cmd/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var colorHiRed = color.New(color.FgHiRed).SprintFunc()
1818

1919
func addAuth(parentCmd *cobra.Command) {
2020
authCmd := &cobra.Command{
21+
GroupID: "configuration",
2122
Short: "Manage user authentication",
2223
Use: "auth",
2324
SilenceUsage: false,

internal/cmd/checklevel.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ func addCheckLevel(parentCmd *cobra.Command) {
4242
opts := checkLevelOpts{}
4343

4444
checklevelCmd := &cobra.Command{
45-
Use: "checklevel",
46-
Short: "Determines the SLSA Source Level of the repo",
45+
Use: "checklevel",
46+
GroupID: "assessment",
47+
Short: "Determines the SLSA Source Level of the repo",
4748
Long: `Determines the SLSA Source Level of the repo.
4849
4950
This is meant to be run within the corresponding GitHub Actions workflow.`,

internal/cmd/checklevelprov.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ func addCheckLevelProv(parentCmd *cobra.Command) {
5151
opts := &checkLevelProvOpts{}
5252

5353
checklevelprovCmd := &cobra.Command{
54-
Use: "checklevelprov",
55-
Short: "Checks the given commit against policy using & creating provenance",
54+
Use: "checklevelprov",
55+
GroupID: "assessment",
56+
Short: "Checks the given commit against policy using & creating provenance",
5657
PreRunE: func(cmd *cobra.Command, args []string) error {
5758
if len(args) > 0 {
5859
if err := opts.ParseLocator(args[0]); err != nil {

internal/cmd/checktag.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ func addCheckTag(parentCmd *cobra.Command) {
5050
opts := &checkTagOptions{}
5151

5252
checktagCmd := &cobra.Command{
53-
Use: "checktag",
54-
Short: "Checks to see if the tag operation should be allowed and issues a VSA",
53+
Use: "checktag",
54+
GroupID: "assessment",
55+
Short: "Checks to see if the tag operation should be allowed and issues a VSA",
5556
RunE: func(cmd *cobra.Command, args []string) error {
5657
return doCheckTag(opts)
5758
},

internal/cmd/createpolicy.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ func addCreatePolicy(parentCmd *cobra.Command) {
3030
opts := createPolicyOptions{}
3131

3232
createpolicyCmd := &cobra.Command{
33-
Use: "createpolicy",
34-
Short: "Creates a policy in a local copy of source-policies",
33+
Use: "createpolicy",
34+
GroupID: "policy",
35+
Short: "Creates a policy in a local copy of source-policies",
3536
Long: `Creates a SLSA source policy in a local copy of source-policies.
3637
3738
The created policy should then be sent as a PR to slsa-framework/source-policies.`,

internal/cmd/policy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ func (pco *policyCreateOpts) AddFlags(cmd *cobra.Command) {
3939

4040
func addPolicy(parentCmd *cobra.Command) {
4141
policyCmd := &cobra.Command{
42-
Short: "tools to work with source policies",
42+
GroupID: "policy",
43+
Short: "tools to work with source policies",
4344
Long: fmt.Sprintf(`
4445
%s %s
4546

internal/cmd/prov.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ func (po *provOptions) AddFlags(cmd *cobra.Command) {
4040
func addProv(parentCmd *cobra.Command) {
4141
opts := provOptions{}
4242
provCmd := &cobra.Command{
43-
Use: "prov",
44-
Short: "Creates provenance for the given commit, but does not check policy.",
43+
Use: "prov",
44+
GroupID: "assessment",
45+
Short: "Creates provenance for the given commit, but does not check policy.",
4546
PreRunE: func(cmd *cobra.Command, args []string) error {
4647
if len(args) > 0 {
4748
if err := opts.ParseLocator(args[0]); err != nil {

internal/cmd/root.go

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,45 @@ controls and much more.
4444

4545
rootCmd.PersistentFlags().StringVar(&githubToken, "github_token", "", "the github token to use for auth")
4646

47-
addCheckLevel(rootCmd)
48-
addCheckLevelProv(rootCmd)
47+
// Define command groups for better organization
48+
rootCmd.AddGroup(
49+
&cobra.Group{
50+
ID: "verification",
51+
Title: "Verification Commands:",
52+
},
53+
&cobra.Group{
54+
ID: "assessment",
55+
Title: "Assessment Commands:",
56+
},
57+
&cobra.Group{
58+
ID: "policy",
59+
Title: "Policy Commands:",
60+
},
61+
&cobra.Group{
62+
ID: "configuration",
63+
Title: "Configuration & Setup Commands:",
64+
},
65+
)
66+
67+
// Verification commands
4968
addVerifyCommit(rootCmd)
50-
addStatus(rootCmd)
51-
addSetup(rootCmd)
5269
addAudit(rootCmd)
53-
addProv(rootCmd)
70+
71+
// Assessment commands
72+
addStatus(rootCmd)
73+
addCheckLevel(rootCmd)
74+
addCheckLevelProv(rootCmd)
5475
addCheckTag(rootCmd)
76+
addProv(rootCmd)
77+
78+
// Policy commands
79+
addPolicy(rootCmd)
5580
addCreatePolicy(rootCmd)
81+
82+
// Configuration & setup commands
83+
addSetup(rootCmd)
5684
addAuth(rootCmd)
57-
addPolicy(rootCmd)
85+
5886
return rootCmd
5987
}
6088

internal/cmd/setup.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ func (so *setupOpts) Validate() error {
5252

5353
func addSetup(parentCmd *cobra.Command) {
5454
setupCmd := &cobra.Command{
55-
Short: "configure SLSA source features in a repository",
55+
GroupID: "configuration",
56+
Short: "configure SLSA source features in a repository",
5657
Long: fmt.Sprintf(`
5758
%s %s
5859

0 commit comments

Comments
 (0)