Skip to content

Added basic clap CLI with subcommand stubs#5

Merged
ubiratansoares merged 2 commits into
rust-lang:mainfrom
Sandijigs:cli-skeleton
Jun 12, 2026
Merged

Added basic clap CLI with subcommand stubs#5
ubiratansoares merged 2 commits into
rust-lang:mainfrom
Sandijigs:cli-skeleton

Conversation

@Sandijigs

Copy link
Copy Markdown
Contributor

Adds the basic CLI using clap. The four commands (list-repos, fetch, analyze, run) just print a placeholder for now. Shared flags for verbose, cache directory, and GitHub token are in place.

Each will get real code in a follow-up PR.

@ubiratansoares ubiratansoares left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sandijigs added a note on your CLI design

Comment thread src/main.rs Outdated
Comment on lines +25 to +39
enum Command {
/// List the Rust project repos
ListRepos,
/// Download workflow files for a repo
Fetch {
/// Repo in the form owner/name
repo: String,
},
/// Run zizmor on a repo's cached workflows
Analyze {
/// Repo in the form owner/name
repo: String,
},
/// List, fetch, and analyze every repo
Run,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only subcommand I agree we need to get started is analyze.

Thinking as someone using the CLI, I see example invocations like

crabwatch analyze rust-lang # org inferred from input parsing
crabwatch analyze --org rust-lang 

crabwatch analyze rust-lang/team # repo inferred from input parsing
crabwatch analyze --repo rust-lang/team 

crabwatch analyze --repo rust-lang/team  --check ci-security # only check with zizmor
crabwatch analyze --org rust-lang  --check dependency-updates # dependabot / renovate in-place?
crabwatch analyze --repo rust-lang/team  --check <some-other-check-we-may-add-later>

# etc

Those are examples, and I think there is room to discuss the CLI design in an upcoming PR, or perhaps a follow-up issue.

Afaict, analyze would handle under the hood the functionalities you defined as subcommands, ie, listing repos in the Github org (when needed), downloading them (when needed), and everything else on demand.

Does that make sense to you?

@Sandijigs Sandijigs Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I went with four subcommands because that's how the task
description listed the steps. but getting started with just analyze is cleaner.
there are a few things I want to confirm before reworking this PR:

  • Should --check take multiple values, or one at a time with all checks
    by default if omitted?
  • For inputs, do you want both positional (crabwatch analyze rust-lang)
    and flagged (--org rust-lang), or just one?
  • For the org-level case, should we filter to repos with crabwatch = true
    (the property from Add custom properties team#2512), or analyze the whole org?

I'll update this PR once we settle these.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should --check take multiple values, or one at a time with all checks by default if omitted?

In this case, I'd assume all as the default value if omitted

For inputs, do you want both positional (crabwatch analyze rust-lang) and flagged (--org rust-lang), or just one?

In general I'd prefer either one of them, but not both of them, for the sake of conciseness if for some reason I have to support more subcommands with more arguments. I think the implementation with flagged arguments might be a bit easier with clap.

For the org-level case, should we filter to repos with crabwatch = true (the property from rust-lang/team#2512), or analyze the whole org?

We should support both in crabwatch, but the ruleset most likely will invoke this CLI passing in the name of repo the associated Github Actions Workflow is running.

Supporting the whole organization is important for us as maintainers, since we can summarize data collected from all the repos in the output, gathering statistics, etc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI is now a single analyze command to start with .
A few small notes on what's in the commit:

  • --repo and --org use clap::ArgGroup so exactly one is required
    and they can't be combined
  • --check is optional. Omitting it means run all checks
  • The CLI doesn't check the crabwatch = true property. --org scans
    every repo in the org

@ubiratansoares ubiratansoares left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@ubiratansoares ubiratansoares merged commit 3eecbbe into rust-lang:main Jun 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants