Skip to content

feat(cli): add inspect command#197

Merged
DorianZheng merged 5 commits intoboxlite-ai:mainfrom
shayne-snap:feat/cli_inspect_command
Feb 6, 2026
Merged

feat(cli): add inspect command#197
DorianZheng merged 5 commits intoboxlite-ai:mainfrom
shayne-snap:feat/cli_inspect_command

Conversation

@shayne-snap
Copy link
Copy Markdown
Contributor

@shayne-snap shayne-snap commented Feb 3, 2026

Info

issue:#35

Key Changes

  • Add boxlite inspect with --latest support
  • Output formats: json, yaml, or Go template (e.g. {{.State}}, {{.Id}})
  • Tests: no args, nonexistent, by name/id, multiple boxes, --latest, formats, table rejected

Testing

  • make test:cli
  • manually test ./target/debug/inspect
./target/debug/boxlite inspect mybox
2026-02-03T05:26:37.963488Z  INFO boxlite::runtime::rt_impl: Virtualization support verified reason=Hypervisor.framework is available (Apple Silicon)
2026-02-03T05:26:37.972045Z  INFO boxlite::runtime::rt_impl: Recovering 3 boxes from database
2026-02-03T05:26:37.972276Z  INFO boxlite::runtime::rt_impl: Box recovery complete
[
  {
    "Id": "01KGGYPMDGGHFR5VFNAEAR5VD6",
    "Name": "mybox",
    "Image": "alpine:latest",
    "Created": "2026-02-03T05:13:15.953411+00:00",
    "Status": "configured",
    "State": {
      "Status": "configured",
      "Running": false,
      "Pid": 0
    },
    "Cpus": 2,
    "Memory": 536870912
  }
]

./target/debug/boxlite create --name mybox alpine:latest

./target/debug/boxlite inspect --latest --format yaml
2026-02-03T05:09:41.131103Z  INFO boxlite::runtime::rt_impl: Virtualization support verified reason=Hypervisor.framework is available (Apple Silicon)
2026-02-03T05:09:41.166768Z  INFO boxlite::runtime::rt_impl: Recovering 2 boxes from database
2026-02-03T05:09:41.167140Z  INFO boxlite::runtime::rt_impl: Box recovery complete
- Id: 01KG4SVPZ7HA3G67ETB08B4Y2Q
  Name: ''
  Image: alpine:latest
  Created: 2026-01-29T11:57:46.344018+00:00
  Status: stopped
  State:
    Status: stopped
    Running: false
    Pid: 0
  Cpus: 2
  Memory: 536870912

@shayne-snap shayne-snap marked this pull request as ready for review February 3, 2026 06:26
DorianZheng
DorianZheng previously approved these changes Feb 6, 2026
Copy link
Copy Markdown
Member

@DorianZheng DorianZheng left a comment

Choose a reason for hiding this comment

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

LGTM

/// Allows callers (e.g. CLI) to build a State view for templates or output
/// without access to internal BoxState. The result is equivalent to
/// `BoxStateInfo::new(state)` when the same box is represented as BoxInfo.
pub fn from_box_info(info: &BoxInfo) -> Self {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use from trait, impl From<BoxInfo> for BoxStateInfo

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.

Done.

shayne-snap and others added 5 commits February 6, 2026 15:46
- Add `boxlite inspect [OPTIONS] BOX [BOX...]` with --latest support
- Output formats: json, yaml, or Go template (e.g. {{.State}}, {{.Id}})
- PascalCase output (Id, Name, Image, State, Cpus, Memory) aligned with Docker/Podman
- Template aliases: .ID -> .Id, .ImageID -> .Image
- Reject table format; use formatter + BoxInfo/BoxStateInfo from boxlite
- Tests: no args, nonexistent, by name/id, multiple boxes, --latest, formats, table rejected

Co-authored-by: Cursor <[email protected]>
…th Docker/Podman

- Formatter: GtmplWithJson parse-once render-many; add json template
  function and format_go_style_value for object output. Remove
  format_gtmpl_with_json; tests use GtmplWithJson::parse().render().
- Inspect: parse template once before loop, serialize each presenter
  to JSON once and reuse for path lookup and gtmpl context. Use
  value_from_serde_json and GtmplWithJson; drop presenter_to_gtmpl_value.
- looks_like_template: require both {{ and }}.
- Add gtmpl_value dep; add inspect tests for template formats.

Co-authored-by: Cursor <[email protected]>
- Replace BoxStateInfo::from_box_info with impl From<&BoxInfo>
- Update inspect command to use BoxStateInfo::from(info)

Co-authored-by: Cursor <[email protected]>
@DorianZheng DorianZheng merged commit 6e601a2 into boxlite-ai:main Feb 6, 2026
13 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