-
Notifications
You must be signed in to change notification settings - Fork 884
Expand file tree
/
Copy pathautostart.go
More file actions
52 lines (46 loc) · 1.51 KB
/
autostart.go
File metadata and controls
52 lines (46 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-FileCopyrightText: Copyright The Lima Authors
// SPDX-License-Identifier: Apache-2.0
package main
import (
"github.com/spf13/cobra"
)
func newAutostartCommand() *cobra.Command {
autostartCommand := &cobra.Command{
Use: "autostart",
Short: "Manage automatic startup of Lima instances",
GroupID: advancedCommand,
}
autostartCommand.AddCommand(newAutostartEnableCommand(), newAutostartDisableCommand())
return autostartCommand
}
func newAutostartEnableCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "enable INSTANCE",
Short: "Register an instance to start automatically",
Args: WrapArgsError(cobra.ExactArgs(1)),
RunE: autostartEnableAction,
ValidArgsFunction: autostartComplete,
}
flags := cmd.Flags()
flags.String(
"condition", "login",
"When to start the instance: \"login\" (user session) or \"boot\" (system boot, macOS only)",
)
flags.String(
"user", "",
"macOS username to run the instance as when --condition=boot (default: $USER)",
)
return cmd
}
func newAutostartDisableCommand() *cobra.Command {
return &cobra.Command{
Use: "disable INSTANCE",
Short: "Unregister an instance from automatic startup",
Args: WrapArgsError(cobra.ExactArgs(1)),
RunE: autostartDisableAction,
ValidArgsFunction: autostartComplete,
}
}
func autostartComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return bashCompleteInstanceNames(cmd)
}