Skip to content

feat: improve CLI#13

Merged
NathaelB merged 1 commit intomainfrom
feat/improve-cli
May 3, 2026
Merged

feat: improve CLI#13
NathaelB merged 1 commit intomainfrom
feat/improve-cli

Conversation

@NathaelB
Copy link
Copy Markdown
Member

@NathaelB NathaelB commented May 3, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Implemented client detail retrieval command
    • Added CLI options to override server URL, OAuth credentials, and default realm via --url, --client-id, --client-secret, and --realm flags (with environment variable support)
    • Made realm argument optional in client commands; defaults to selected context
  • Chores

    • Updated crate metadata and workspace dependencies
    • Optimized Docker build pipeline with cached dependency compilation
    • Added automated Rust crate publishing workflow

@NathaelB NathaelB self-assigned this May 3, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4bd19ff4-efc1-498c-ae34-87881146ca6e

📥 Commits

Reviewing files that changed from the base of the PR and between fa004ee and 4c20171.

📒 Files selected for processing (11)
  • .github/workflows/crates-io.yaml
  • .github/workflows/docker.yaml
  • CLAUDE.md
  • Cargo.toml
  • Dockerfile
  • libs/ferriskey-cli-core/Cargo.toml
  • libs/ferriskey-cli-core/src/client.rs
  • libs/ferriskey-cli-core/src/lib.rs
  • libs/ferriskey-commands/Cargo.toml
  • libs/ferriskey-commands/src/client.rs
  • libs/ferriskey-commands/src/lib.rs

📝 Walkthrough

Walkthrough

This PR adds CLI-level context override support (URL, client credentials, realm) with a new get_client implementation, updates Cargo workspace metadata (license, repository, homepage), optimizes Docker builds using cargo-chef, establishes CI workflows for crates.io publishing and tag-based container releases, and documents the CLI architecture via CLAUDE.md.

Changes

CLI Context Override & Client Get Implementation

Layer / File(s) Summary
CLI Arguments
libs/ferriskey-commands/src/lib.rs, libs/ferriskey-commands/src/client.rs
Root Cli struct gains optional --url, --client-id, --client-secret, --realm flags with env var backing. ClientGetArgs and ClientDeleteArgs change realm from required String to optional Option<String>.
Inline Context Building
libs/ferriskey-cli-core/src/lib.rs
New build_inline_context() helper constructs a StoredContext from CLI-provided credentials when all three (url, client_id, client_secret) are present. run() threads inline_context into client::run().
Client Command Implementation
libs/ferriskey-cli-core/src/client.rs
run() accepts inline_context parameter and passes it to subcommands. get_client() newly implemented to resolve context, perform OAuth client-credentials exchange, fetch client, handle ClientNotFound, and render via new ClientDetailView. list_clients() and create_client() updated to use resolve_context() helper that prefers inline_context over on-disk storage.
Output Rendering
libs/ferriskey-cli-core/src/client.rs
New ClientDetailView and helpers to_detail_view(), render_client_detail() provide table, json, yaml formatting for client details. ClientCommandError adds ClientNotFound(String) variant.
Dependency Versions
libs/ferriskey-cli-core/Cargo.toml
Explicit version = "0.1.0" added to ferriskey-client and ferriskey-commands path dependencies.

Workspace & Package Metadata

Layer / File(s) Summary
Workspace Package Definition
Cargo.toml
[workspace.package] establishes shared license = "Apache-2.0", repository, and homepage fields.
Package Metadata References
Cargo.toml, libs/ferriskey-cli-core/Cargo.toml, libs/ferriskey-commands/Cargo.toml
All crates now pull license, repository, homepage from workspace via .workspace = true. Descriptions set per crate. Root Cargo.toml also adds explicit version = "0.1.0" to path dependencies.
CLI Feature Enhancement
libs/ferriskey-commands/Cargo.toml
Clap dependency updated to include "env" feature alongside "derive" to enable environment variable binding for CLI arguments.

Build & Deployment Infrastructure

Layer / File(s) Summary
Docker Build Optimization
Dockerfile
Multi-stage pipeline replaced with cargo-chef workflow (chef/planner, builder stages) for improved dependency caching. Old rust-build and api stages removed; new cli stage copies release binary to /usr/local/bin/. Removes EXPOSE 80.
Crates.io Publishing Workflow
.github/workflows/crates-io.yaml
New workflow publishes on v*.*.* tag push or manual dispatch. Verifies tag matches ferriskey crate version, runs tests and clippy with strict warnings, then publishes ferriskey-commands, ferriskey-client, ferriskey-cli-core, ferriskey in order with helpers to skip if already published and poll for availability (up to ~5 min).
Docker Build Triggers
.github/workflows/docker.yaml
Adds tag-based triggering for v*.*.* and v*.*.*-rc* patterns. Limits push and pull_request events to main branch.

Documentation

Layer / File(s) Summary
Architecture & Guidance
CLAUDE.md
Documents workspace build/test/lint commands, 4-crate architecture, CLI argument → handler → client API data flow, TOML config storage with atomic writes, output format control (table/json/yaml), unimplemented command stubs, and OAuth2 client-credentials token exchange requirement.

Sequence Diagram(s)

sequenceDiagram
    participant User as CLI User
    participant CLI as ferriskey (CLI)
    participant CliCore as ferriskey-cli-core
    participant Ctx as Context Resolver
    participant OAuth as OAuth/API
    participant Output as Output Renderer

    User->>CLI: ferriskey --url=... --client-id=... --client-secret=... client get realm/client-123
    CLI->>CliCore: client::run(inline_context, command)
    CliCore->>Ctx: resolve_context(inline_context)
    Ctx->>CliCore: StoredContext (from CLI args)
    CliCore->>OAuth: exchange_client_credentials(context)
    OAuth->>CliCore: Bearer token
    CliCore->>OAuth: GET /clients/{realm}/{id}
    OAuth->>CliCore: ClientRepresentation | 404
    CliCore->>Output: render_client_detail(to_detail_view(...), format)
    Output->>User: table | json | yaml output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The PR spans multiple distinct areas (CLI args, client implementation, metadata updates, Docker/CI workflows, documentation), with moderate logic density in the client context resolution and detail rendering. The heterogeneity of file types (manifest updates, workflow YAML, Dockerfile, Rust implementation) and the need to verify correct threading of inline_context through multiple layers adds some complexity, though most changes follow consistent patterns.

Poem

🐰 A rabbit hops through context and CLI,
With client credentials ready to fly,
cargo-chef speeds the build so right,
While workflows publish releases with might,
Details rendered in table, json, and yaml bright!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/improve-cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@NathaelB NathaelB merged commit 1af390e into main May 3, 2026
1 check was pending
@NathaelB NathaelB deleted the feat/improve-cli branch May 3, 2026 23:51
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.

1 participant