Skip to content

Commit 141284e

Browse files
committed
limactl: improve help output
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 2470386 commit 141284e

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

cmd/limactl/main.go

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package main
22

33
import (
44
"errors"
5+
"fmt"
56
"os"
7+
"path/filepath"
68
"strings"
79

810
"github.com/lima-vm/lima/pkg/store/dirnames"
@@ -23,10 +25,30 @@ func main() {
2325
}
2426

2527
func newApp() *cobra.Command {
28+
examplesDir := "$PREFIX/share/doc/lima/examples"
29+
if exe, err := os.Executable(); err == nil {
30+
binDir := filepath.Dir(exe)
31+
prefixDir := filepath.Dir(binDir)
32+
examplesDir = filepath.Join(prefixDir, "share/doc/lima/examples")
33+
}
34+
2635
var rootCmd = &cobra.Command{
27-
Use: "limactl",
28-
Short: "Lima: Linux virtual machines",
29-
Version: strings.TrimPrefix(version.Version, "v"),
36+
Use: "limactl",
37+
Short: "Lima: Linux virtual machines",
38+
Version: strings.TrimPrefix(version.Version, "v"),
39+
Example: fmt.Sprintf(` Start the default instance:
40+
$ limactl start
41+
42+
Open a shell:
43+
$ lima
44+
45+
Run a container:
46+
$ lima nerdctl run -d --name nginx -p 8080:80 nginx:alpine
47+
48+
Stop the default instance:
49+
$ limactl stop
50+
51+
See also example YAMLs: %s`, examplesDir),
3052
SilenceUsage: true,
3153
SilenceErrors: true,
3254
}

0 commit comments

Comments
 (0)