@@ -192,7 +192,146 @@ func confirmInput(msg string) (bool, error) {
192
192
return confirmed , nil
193
193
}
194
194
195
- var Commands = []cli.Command {}
195
+ var Commands = []cli.Command {
196
+ {
197
+ Flags : SharedCreateFlags ,
198
+ Name : "create" ,
199
+ Usage : "Create a machine" ,
200
+ Description : fmt .Sprintf ("Run '%s create --driver name' to include the create flags for that driver in the help text." , os .Args [0 ]),
201
+ Action : runCommand (cmdCreateOuter ),
202
+ SkipFlagParsing : true ,
203
+ },
204
+ {
205
+ Name : "inspect" ,
206
+ Usage : "Inspect information about a machine" ,
207
+ Description : "Argument is a machine name." ,
208
+ Action : runCommand (cmdInspect ),
209
+ Flags : []cli.Flag {
210
+ cli.StringFlag {
211
+ Name : "format, f" ,
212
+ Usage : "Format the output using the given go template." ,
213
+ Value : "" ,
214
+ },
215
+ },
216
+ },
217
+ {
218
+ Name : "ip" ,
219
+ Usage : "Get the IP address of a machine" ,
220
+ Description : "Argument(s) are one or more machine names." ,
221
+ Action : runCommand (cmdIP ),
222
+ },
223
+ {
224
+ Name : "kill" ,
225
+ Usage : "Kill a machine" ,
226
+ Description : "Argument(s) are one or more machine names." ,
227
+ Action : runCommand (cmdKill ),
228
+ },
229
+ {
230
+ Name : "ls" ,
231
+ Usage : "List machines" ,
232
+ Action : runCommand (cmdLs ),
233
+ Flags : []cli.Flag {
234
+ cli.BoolFlag {
235
+ Name : "quiet, q" ,
236
+ Usage : "Enable quiet mode" ,
237
+ },
238
+ cli.StringSliceFlag {
239
+ Name : "filter" ,
240
+ Usage : "Filter output based on conditions provided" ,
241
+ Value : & cli.StringSlice {},
242
+ },
243
+ cli.IntFlag {
244
+ Name : "timeout, t" ,
245
+ Usage : fmt .Sprintf ("Timeout in seconds, default to %ds" , lsDefaultTimeout ),
246
+ Value : lsDefaultTimeout ,
247
+ },
248
+ cli.StringFlag {
249
+ Name : "format, f" ,
250
+ Usage : "Pretty-print machines using a Go template" ,
251
+ },
252
+ },
253
+ },
254
+ {
255
+ Name : "restart" ,
256
+ Usage : "Restart a machine" ,
257
+ Description : "Argument(s) are one or more machine names." ,
258
+ Action : runCommand (cmdRestart ),
259
+ },
260
+ {
261
+ Flags : []cli.Flag {
262
+ cli.BoolFlag {
263
+ Name : "force, f" ,
264
+ Usage : "Remove local configuration even if machine cannot be removed, also implies an automatic yes (`-y`)" ,
265
+ },
266
+ cli.BoolFlag {
267
+ Name : "y" ,
268
+ Usage : "Assumes automatic yes to proceed with remove, without prompting further user confirmation" ,
269
+ },
270
+ },
271
+ Name : "rm" ,
272
+ Usage : "Remove a machine" ,
273
+ Description : "Argument(s) are one or more machine names." ,
274
+ Action : runCommand (cmdRm ),
275
+ },
276
+ {
277
+ Name : "ssh" ,
278
+ Usage : "Log into or run a command on a machine with SSH." ,
279
+ Description : "Arguments are [machine-name] [command]" ,
280
+ Action : runCommand (cmdSSH ),
281
+ SkipFlagParsing : true ,
282
+ },
283
+ {
284
+ Name : "scp" ,
285
+ Usage : "Copy files between machines" ,
286
+ Description : "Arguments are [machine:][path] [machine:][path]." ,
287
+ Action : runCommand (cmdScp ),
288
+ Flags : []cli.Flag {
289
+ cli.BoolFlag {
290
+ Name : "recursive, r" ,
291
+ Usage : "Copy files recursively (required to copy directories)" ,
292
+ },
293
+ cli.BoolFlag {
294
+ Name : "delta, d" ,
295
+ Usage : "Reduce amount of data sent over network by sending only the differences (uses rsync)" ,
296
+ },
297
+ },
298
+ },
299
+ {
300
+ Name : "start" ,
301
+ Usage : "Start a machine" ,
302
+ Description : "Argument(s) are one or more machine names." ,
303
+ Action : runCommand (cmdStart ),
304
+ },
305
+ {
306
+ Name : "status" ,
307
+ Usage : "Get the status of a machine" ,
308
+ Description : "Argument is a machine name." ,
309
+ Action : runCommand (cmdStatus ),
310
+ },
311
+ {
312
+ Name : "stop" ,
313
+ Usage : "Stop a machine" ,
314
+ Description : "Argument(s) are one or more machine names." ,
315
+ Action : runCommand (cmdStop ),
316
+ },
317
+ {
318
+ Name : "updatecli" ,
319
+ Usage : "Update Lambda Machine Local CLI to the latest version" ,
320
+ Action : runCommand (cmdUpdateCli ),
321
+ },
322
+ // docker-machine calls this upgrade, but we call it updateiso
323
+ {
324
+ Name : "updateiso" ,
325
+ Usage : "Update machine ISO image to the latest version" ,
326
+ Description : "Argument(s) are one or more machine names." ,
327
+ Action : runCommand (cmdUpgrade ),
328
+ },
329
+ {
330
+ Name : "version" ,
331
+ Usage : "Show the Lambda Machine Local version" ,
332
+ Action : runCommand (cmdVersion ),
333
+ },
334
+ }
196
335
197
336
func printIP (h * host.Host ) func () error {
198
337
return func () error {
@@ -211,7 +350,14 @@ func printIP(h *host.Host) func() error {
211
350
// We run commands concurrently and communicate back an error if there was one.
212
351
func machineCommand (actionName string , host * host.Host , errorChan chan <- error ) {
213
352
// TODO: These actions should have their own type.
214
- commands := map [string ](func () error ){}
353
+ commands := map [string ](func () error ){
354
+ "start" : host .Start ,
355
+ "stop" : host .Stop ,
356
+ "restart" : host .Restart ,
357
+ "kill" : host .Kill ,
358
+ "ip" : printIP (host ),
359
+ "upgrade" : host .Upgrade ,
360
+ }
215
361
216
362
log .Debugf ("command=%s machine=%s" , actionName , host .Name )
217
363
0 commit comments