Skip to content

feat(cardwire-cli): add a cardwire launch program - #145

Merged
luytan merged 2 commits into
mainfrom
cli-launch-program-switcheroo-like
Aug 5, 2026
Merged

feat(cardwire-cli): add a cardwire launch program#145
luytan merged 2 commits into
mainfrom
cli-launch-program-switcheroo-like

Conversation

@luytan

@luytan luytan commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Description

Launch a program with cardwire ENVs using the switcheroo shim

TODO

  • Copy-Paste this line

Checklist:

  • My code follows the style guidelines of this project (cargo fmt)
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the mdBook documentation
  • My changes generate no new warnings (clippy/clang)
  • New and existing unit tests pass locally with my changes (either use nix flake check or wait for the ci)

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fbeeb163-87c6-4cd4-8ad4-090a5cd0a5f1

📥 Commits

Reviewing files that changed from the base of the PR and between 973c6c7 and 22c9cc1.

📒 Files selected for processing (1)
  • crates/cardwire-cli/src/main.rs

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added a launch command for running programs with a selected GPU.
    • Supports choosing a GPU by ID or automatically selecting a preferred available option.
    • Preserves GPU-specific environment settings when launching programs.
    • Supports program names and arguments beginning with hyphens.
    • Reports launch failures and unsuccessful program exits.

Walkthrough

The CLI adds a Launch command. It reads SwitcherooControl GPU metadata, selects a requested or preferred GPU, applies its environment variables, and launches the specified program. Successful launches currently return a “No matching GPU found” error.

Changes

GPU-aware launch

Layer / File(s) Summary
Launch command contract
crates/cardwire-cli/src/args.rs
Adds Commands::Launch with optional --gpu selection and trailing program arguments.
GPU discovery and process launch
crates/cardwire-cli/src/dbus.rs, crates/cardwire-cli/src/main.rs
Queries SwitcherooControl, parses GPU metadata, selects a GPU, applies paired environment variables, launches the program, and reports launch or exit failures. A successful launch returns an incorrect “No matching GPU found” error.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as cardwire CLI
  participant DaemonClient
  participant SwitcherooControl
  participant Program as Requested program
  CLI->>DaemonClient: get_gpu_switcheroo()
  DaemonClient->>SwitcherooControl: Read GPUs property
  SwitcherooControl-->>DaemonClient: GPU property maps
  DaemonClient-->>CLI: GPU metadata
  CLI->>Program: Launch with selected GPU environment and arguments
  Program-->>CLI: Exit status
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding a cardwire launch program to the CLI.
Description check ✅ Passed The description summarizes the feature, states its motivation, and includes the TODO and checklist sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/cardwire-cli/src/main.rs`:
- Around line 329-339: Update the launch command flow in main to return a
failure result when the child process exits unsuccessfully, command.status()
fails, no GPUs are found, or the --gpu selection matches no entry; preserve
successful execution as Ok(()) and propagate an appropriate error status for
each failure branch.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8d21780b-fc0d-452f-ba11-f0a8fd86e091

📥 Commits

Reviewing files that changed from the base of the PR and between df02ca6 and 973c6c7.

📒 Files selected for processing (3)
  • crates/cardwire-cli/src/args.rs
  • crates/cardwire-cli/src/dbus.rs
  • crates/cardwire-cli/src/main.rs

Comment thread crates/cardwire-cli/src/main.rs Outdated
@luytan
luytan merged commit 5fd38e9 into main Aug 5, 2026
7 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.

1 participant