@@ -192,7 +192,195 @@ 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
+ Name : "active" ,
198
+ Usage : "Print which machine is active" ,
199
+ Action : runCommand (cmdActive ),
200
+ Flags : []cli.Flag {
201
+ cli.IntFlag {
202
+ Name : "timeout, t" ,
203
+ Usage : fmt .Sprintf ("Timeout in seconds, default to %ds" , activeDefaultTimeout ),
204
+ Value : activeDefaultTimeout ,
205
+ },
206
+ },
207
+ },
208
+ {
209
+ Name : "config" ,
210
+ Usage : "Print the connection config for machine" ,
211
+ Description : "Argument is a machine name." ,
212
+ Action : runCommand (cmdConfig ),
213
+ },
214
+ {
215
+ Flags : SharedCreateFlags ,
216
+ Name : "create" ,
217
+ Usage : "Create a machine" ,
218
+ Description : fmt .Sprintf ("Run '%s create --driver name' to include the create flags for that driver in the help text." , os .Args [0 ]),
219
+ Action : runCommand (cmdCreateOuter ),
220
+ SkipFlagParsing : true ,
221
+ },
222
+ {
223
+ Name : "env" ,
224
+ Usage : "Display the commands to set up the environment for the Docker client" ,
225
+ Description : "Argument is a machine name." ,
226
+ Action : runCommand (cmdEnv ),
227
+ Flags : []cli.Flag {
228
+ cli.StringFlag {
229
+ Name : "shell" ,
230
+ Usage : "Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh], default is auto-detect" ,
231
+ },
232
+ cli.BoolFlag {
233
+ Name : "unset, u" ,
234
+ Usage : "Unset variables instead of setting them" ,
235
+ },
236
+ cli.BoolFlag {
237
+ Name : "no-proxy" ,
238
+ Usage : "Add machine IP to NO_PROXY environment variable" ,
239
+ },
240
+ },
241
+ },
242
+ {
243
+ Name : "inspect" ,
244
+ Usage : "Inspect information about a machine" ,
245
+ Description : "Argument is a machine name." ,
246
+ Action : runCommand (cmdInspect ),
247
+ Flags : []cli.Flag {
248
+ cli.StringFlag {
249
+ Name : "format, f" ,
250
+ Usage : "Format the output using the given go template." ,
251
+ Value : "" ,
252
+ },
253
+ },
254
+ },
255
+ {
256
+ Name : "ip" ,
257
+ Usage : "Get the IP address of a machine" ,
258
+ Description : "Argument(s) are one or more machine names." ,
259
+ Action : runCommand (cmdIP ),
260
+ },
261
+ {
262
+ Name : "kill" ,
263
+ Usage : "Kill a machine" ,
264
+ Description : "Argument(s) are one or more machine names." ,
265
+ Action : runCommand (cmdKill ),
266
+ },
267
+ {
268
+ Name : "ls" ,
269
+ Usage : "List machines" ,
270
+ Action : runCommand (cmdLs ),
271
+ Flags : []cli.Flag {
272
+ cli.BoolFlag {
273
+ Name : "quiet, q" ,
274
+ Usage : "Enable quiet mode" ,
275
+ },
276
+ cli.StringSliceFlag {
277
+ Name : "filter" ,
278
+ Usage : "Filter output based on conditions provided" ,
279
+ Value : & cli.StringSlice {},
280
+ },
281
+ cli.IntFlag {
282
+ Name : "timeout, t" ,
283
+ Usage : fmt .Sprintf ("Timeout in seconds, default to %ds" , lsDefaultTimeout ),
284
+ Value : lsDefaultTimeout ,
285
+ },
286
+ cli.StringFlag {
287
+ Name : "format, f" ,
288
+ Usage : "Pretty-print machines using a Go template" ,
289
+ },
290
+ },
291
+ },
292
+ {
293
+ Name : "provision" ,
294
+ Usage : "Re-provision existing machines" ,
295
+ Action : runCommand (cmdProvision ),
296
+ },
297
+ {
298
+ Name : "regenerate-certs" ,
299
+ Usage : "Regenerate TLS Certificates for a machine" ,
300
+ Description : "Argument(s) are one or more machine names." ,
301
+ Action : runCommand (cmdRegenerateCerts ),
302
+ Flags : []cli.Flag {
303
+ cli.BoolFlag {
304
+ Name : "force, f" ,
305
+ Usage : "Force rebuild and do not prompt" ,
306
+ },
307
+ },
308
+ },
309
+ {
310
+ Name : "restart" ,
311
+ Usage : "Restart a machine" ,
312
+ Description : "Argument(s) are one or more machine names." ,
313
+ Action : runCommand (cmdRestart ),
314
+ },
315
+ {
316
+ Flags : []cli.Flag {
317
+ cli.BoolFlag {
318
+ Name : "force, f" ,
319
+ Usage : "Remove local configuration even if machine cannot be removed, also implies an automatic yes (`-y`)" ,
320
+ },
321
+ cli.BoolFlag {
322
+ Name : "y" ,
323
+ Usage : "Assumes automatic yes to proceed with remove, without prompting further user confirmation" ,
324
+ },
325
+ },
326
+ Name : "rm" ,
327
+ Usage : "Remove a machine" ,
328
+ Description : "Argument(s) are one or more machine names." ,
329
+ Action : runCommand (cmdRm ),
330
+ },
331
+ {
332
+ Name : "ssh" ,
333
+ Usage : "Log into or run a command on a machine with SSH." ,
334
+ Description : "Arguments are [machine-name] [command]" ,
335
+ Action : runCommand (cmdSSH ),
336
+ SkipFlagParsing : true ,
337
+ },
338
+ {
339
+ Name : "scp" ,
340
+ Usage : "Copy files between machines" ,
341
+ Description : "Arguments are [machine:][path] [machine:][path]." ,
342
+ Action : runCommand (cmdScp ),
343
+ Flags : []cli.Flag {
344
+ cli.BoolFlag {
345
+ Name : "recursive, r" ,
346
+ Usage : "Copy files recursively (required to copy directories)" ,
347
+ },
348
+ cli.BoolFlag {
349
+ Name : "delta, d" ,
350
+ Usage : "Reduce amount of data sent over network by sending only the differences (uses rsync)" ,
351
+ },
352
+ },
353
+ },
354
+ {
355
+ Name : "start" ,
356
+ Usage : "Start a machine" ,
357
+ Description : "Argument(s) are one or more machine names." ,
358
+ Action : runCommand (cmdStart ),
359
+ },
360
+ {
361
+ Name : "status" ,
362
+ Usage : "Get the status of a machine" ,
363
+ Description : "Argument is a machine name." ,
364
+ Action : runCommand (cmdStatus ),
365
+ },
366
+ {
367
+ Name : "stop" ,
368
+ Usage : "Stop a machine" ,
369
+ Description : "Argument(s) are one or more machine names." ,
370
+ Action : runCommand (cmdStop ),
371
+ },
372
+ {
373
+ Name : "url" ,
374
+ Usage : "Get the URL of a machine" ,
375
+ Description : "Argument is a machine name." ,
376
+ Action : runCommand (cmdURL ),
377
+ },
378
+ {
379
+ Name : "version" ,
380
+ Usage : "Show the Lambda Machine Local version or a machine docker version" ,
381
+ Action : runCommand (cmdVersion ),
382
+ },
383
+ }
196
384
197
385
func printIP (h * host.Host ) func () error {
198
386
return func () error {
@@ -211,7 +399,15 @@ func printIP(h *host.Host) func() error {
211
399
// We run commands concurrently and communicate back an error if there was one.
212
400
func machineCommand (actionName string , host * host.Host , errorChan chan <- error ) {
213
401
// TODO: These actions should have their own type.
214
- commands := map [string ](func () error ){}
402
+ commands := map [string ](func () error ){
403
+ "configureAuth" : host .ConfigureAuth ,
404
+ "start" : host .Start ,
405
+ "stop" : host .Stop ,
406
+ "restart" : host .Restart ,
407
+ "kill" : host .Kill ,
408
+ "ip" : printIP (host ),
409
+ "provision" : host .Provision ,
410
+ }
215
411
216
412
log .Debugf ("command=%s machine=%s" , actionName , host .Name )
217
413
0 commit comments