Skip to content

Commit

Permalink
cmd: Add 'version' option
Browse files Browse the repository at this point in the history
This 'version' option prints the fakemachine version

Signed-off-by: Dylan Aïssi <[email protected]>
  • Loading branch information
daissi authored and sjoerdsimons committed Nov 9, 2024
1 parent de16751 commit 019ca7f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/fakemachine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"strings"
)

const Version = "0.0.10"

type Options struct {
Backend string `short:"b" long:"backend" description:"Virtualisation backend to use" default:"auto"`
Volumes []string `short:"v" long:"volume" description:"volume to mount"`
Expand All @@ -21,6 +23,7 @@ type Options struct {
ScratchSize string `short:"s" long:"scratchsize" description:"On-disk scratch space size (with a unit suffix, e.g. 4G); if unset, memory backed scratch space is used"`
ShowBoot bool `long:"show-boot" description:"Show boot/console messages from the fakemachine"`
Quiet bool `short:"q" long:"quiet" description:"Don't show logs from fakemachine or the backend; only print the command's stdout/stderr"`
Version bool `long:"version" description:"Print fakemachine version"`
}

var options Options
Expand Down Expand Up @@ -151,6 +154,11 @@ func main() {
}
}

if options.Version {
fmt.Printf("fakemachine v%s\n", Version)
return
}

m, err := fakemachine.NewMachineWithBackend(options.Backend)
if err != nil {
fmt.Printf("fakemachine: %v\n", err)
Expand Down

0 comments on commit 019ca7f

Please sign in to comment.