model,cli,docs: medium-effort polish for v0.1.0

* model.ParseSize / FormatSizeBytes: pinned with table tests in
    internal/model/types_test.go (TestParseSize 22 cases,
    TestFormatSizeBytes 11 cases, TestParseSizeFormatRoundTrip 7
    boundaries). Fixed the long-suffix regression: "4GiB", "512MiB",
    "4KiB" now parse correctly (parser strips trailing IB before
    inspecting the unit byte). Pinned current behaviour for
    no-suffix input ("1024" treated as MiB) and FormatSizeBytes(0).
    commands_image.go --size flag-help updated to show 4GiB now
    that the parser accepts it.
  * vm ports --json: matches the JSON-vs-table inconsistency between
    vm stats (always JSON) and vm ports (always table). --json on
    vm ports flips to the same printJSON path as vm stats. Default
    table output unchanged. Other vm subcommands (show, stats,
    logs, health, ping) didn't fit the identical pattern; left
    alone.
  * docs/oci-import.md architecture section moved to a new
    docs/oci-import-internals.md (precedent: internal/daemon/
    ARCHITECTURE.md). User-facing oci-import.md keeps a one-line
    pointer for advanced reading.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thales Maciel 2026-04-28 17:36:03 -03:00
parent 4d8dca6b72
commit d0997fd3b5
No known key found for this signature in database
GPG key ID: 33112E6833C34679
6 changed files with 196 additions and 42 deletions

View file

@ -235,7 +235,7 @@ subcommand lands).
cmd.Flags().StringVar(&params.InitrdPath, "initrd", "", "initrd path")
cmd.Flags().StringVar(&params.ModulesDir, "modules", "", "modules dir")
cmd.Flags().StringVar(&params.KernelRef, "kernel-ref", "", "name of a cataloged kernel (see 'banger kernel list')")
cmd.Flags().StringVar(&sizeRaw, "size", "", "ext4 image size (e.g. 4GiB); defaults to content + 25%, min 1GiB")
cmd.Flags().StringVar(&sizeRaw, "size", "", "ext4 image size, e.g. 4GiB, 512M, 2G (defaults to content + 25%, min 1GiB)")
_ = cmd.RegisterFlagCompletionFunc("kernel-ref", d.completeKernelNames)
return cmd
}

View file

@ -875,7 +875,8 @@ func (d *deps) newVMStatsCommand() *cobra.Command {
}
func (d *deps) newVMPortsCommand() *cobra.Command {
return &cobra.Command{
var jsonOut bool
cmd := &cobra.Command{
Use: "ports <id-or-name>",
Short: "Show host-reachable listening guest ports",
Args: exactArgsUsage(1, "usage: banger vm ports <id-or-name>"),
@ -889,9 +890,14 @@ func (d *deps) newVMPortsCommand() *cobra.Command {
if err != nil {
return err
}
if jsonOut {
return printJSON(cmd.OutOrStdout(), result)
}
return printVMPortsTable(cmd.OutOrStdout(), result)
},
}
cmd.Flags().BoolVar(&jsonOut, "json", false, "print ports as JSON instead of a table")
return cmd
}
type resolvedVMTarget struct {