8000 feat: migrate CLI to Cobra/Viper (#93) by frrist · Pull Request #110 · storacha/piri · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: migrate CLI to Cobra/Viper (#93) #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 20, 2025
Merged

feat: migrate CLI to Cobra/Viper (#93) #110

merged 5 commits into from
Jun 20, 2025

Conversation

frrist
Copy link
Member
@frrist frrist commented Jun 12, 2025

Restructure CLI with clear separation between server and client operations,
replacing urfave/cli with Cobra and Viper for improved configuration management.

Architecture changes:

  • Introduce piri serve <ucan|pdp> for running different server types:
    • piri serve pdp: Start PDP (Provable Data Possession) server
    • piri serve ucan: Start UCAN authorization server
  • Add piri client commands for interacting with servers:
    • piri client upload: Upload data to storage servers
    • piri client pdp: PDP-specific client operations
      • piece info/management
      • proofset create/get/status operations
  • Clear separation of concerns between server hosting and client interactions

Configuration improvements:

  • Unified config system supporting TOML files, env vars (PIRI_), and CLI flags
  • Type-safe configuration with validation
  • Proper precedence: flags > env > config file > defaults

Closes #93

@frrist frrist force-pushed the frrist/feat/snake-pit branch from 09f2860 to bf4b3e9 Compare June 12, 2025 23:03
@@ -1,41 +0,0 @@
package main
Copy link
Member Author

Choose a reason for hiding this comment

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

I've assumed this was a one-off helper, and removed it, I don't see it referenced anywhere in the go code or terraform.

@@ -48,7 +48,8 @@ func (p *PDPService) ProofSet(ctx context.Context, id int64) (*ProofSet, error)

// Step 5: Build the response.
response := &ProofSet{
ID: proofSet.ID,
ID: proofSet.ID,
// TODO this will panic if ProveAtEpoch is nill, which it is when the proofset is first created
Copy link
Member Author

Choose a reason for hiding this comment

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

Not caused by this change, but found during testing - #111

@frrist frrist requested review from hannahhoward and volmedo June 12, 2025 23:06
@frrist frrist force-pushed the frrist/feat/snake-pit branch 2 times, most recently from 8585fd7 to e535ce1 Compare June 16, 2025 19:37
@frrist frrist force-pushed the frrist/feat/snake-pit branch from e535ce1 to 4dbe20b Compare June 17, 2025 18:39
Copy link
Member
@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

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

Overall LGTM and excited with this transition -- the automatic env var generation is great as are the config files.

This definitely gets me excited to expand the surface area of cobra/viper to other repos

`,
}

GenerateCmd = &cobra.Command{
Copy link
Member

Choose a reason for hiding this comment

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

random formatting question -- why is generate declared up here but parse is declared below?

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, I got lazy, moved Parse to this same var declaration block.

@@ -0,0 +1,52 @@
package api
Copy link
Member

Choose a reason for hiding this comment

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

just curious: how is this an API?

Copy link
Member Author

Choose a reason for hiding this comment

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

ehh, it's not - naming is hard - renamed this to client.

frrist added 3 commits June 20, 2025 11:11
…93)

  Restructure CLI with clear separation between server and client operations,
  replacing urfave/cli with Cobra and Viper for improved configuration management.

  Architecture changes:
  - Introduce `piri serve <ucan|pdp>` for running different server types:
    - `piri serve pdp`: Start PDP (Provable Data Possession) server
    - `piri serve ucan`: Start UCAN authorization server
  - Add `piri client` commands for interacting with servers:
    - `piri client upload`: Upload data to storage servers
    - `piri client pdp`: PDP-specific client operations
      - piece info/management
      - proofset create/get/status operations
  - Clear separation of concerns between server hosting and client interactions

  Configuration improvements:
  - Unified config system supporting TOML files, env vars (PIRI_), and CLI flags
  - Type-safe configuration with validation
  - Proper precedence: flags > env > config file > defaults
@frrist frrist force-pushed the frrist/feat/snake-pit branch from 4dbe20b to 76a60c3 Compare June 20, 2025 18:11
@frrist frrist merged commit 208b658 into main Jun 20, 2025
8 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.

Migrate CLI and Configuration to Cobra + Viper
2 participants
0