@@ -75,10 +75,8 @@ func readDefaultTemplate() ([]byte, error) {
75
75
}
76
76
77
77
func loadOrCreateInstance (cmd * cobra.Command , args []string ) (* store.Instance , error ) {
78
- var arg string
79
- if len (args ) == 0 {
80
- arg = DefaultInstanceName
81
- } else {
78
+ var arg string // can be empty
79
+ if len (args ) > 0 {
82
80
arg = args [0 ]
83
81
}
84
82
@@ -154,22 +152,31 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string) (*store.Instance, e
154
152
return nil , err
155
153
}
156
154
} else {
157
- logrus .Debugf ("interpreting argument %q as an instance name" , arg )
158
- if st .instName != "" && st .instName != arg {
159
- return nil , fmt .Errorf ("instance name %q and CLI flag --name=%q cannot be specified together" , arg , st .instName )
155
+ if arg == "" {
156
+ if st .instName == "" {
157
+ st .instName = DefaultInstanceName
158
+ }
159
+ } else {
160
+ logrus .Debugf ("interpreting argument %q as an instance name" , arg )
161
+ if st .instName != "" && st .instName != arg {
162
+ return nil , fmt .Errorf ("instance name %q and CLI flag --name=%q cannot be specified together" , arg , st .instName )
163
+ }
164
+ st .instName = arg
160
165
}
161
- st .instName = arg
162
166
if err := identifiers .Validate (st .instName ); err != nil {
163
167
return nil , fmt .Errorf ("argument must be either an instance name, a YAML file path, or a URL, got %q: %w" , st .instName , err )
164
168
}
165
169
if inst , err := store .Inspect (st .instName ); err == nil {
166
170
logrus .Infof ("Using the existing instance %q" , st .instName )
171
+ if arg == "" {
172
+ logrus .Infof ("Hint: To create another instance, run the following command: limactl start --name=NAME template://default" )
173
+ }
167
174
return inst , nil
168
175
} else {
169
176
if ! errors .Is (err , os .ErrNotExist ) {
170
177
return nil , err
171
178
}
172
- if st . instName != DefaultInstanceName {
179
+ if arg != "" && arg != DefaultInstanceName {
173
180
logrus .Infof ("Creating an instance %q from template://default (Not from template://%s)" , st .instName , st .instName )
174
181
logrus .Warnf ("This form is deprecated. Use `limactl start --name=%s template://default` instead" , st .instName )
175
182
}
0 commit comments