The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2181
This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.
=== Description (from pull-request) ===
From dd70184330e3e70bab36363bfe40177ce5b7d56f Mon Sep 17 00:00:00 2001
From: Tycho Andersen
Date: Wed, 6 Jul 2016 15:35:51 -0600
Subject: [PATCH 1/2] use named args for actionCmds
We'll take advantage of this in the next patch making the diff much
shorter.
Signed-off-by: Tycho Andersen
---
lxc/main.go | 55 +--
1 file changed, 37 insertions(+), 18 deletions(-)
diff --git a/lxc/main.go b/lxc/main.go
index ff8b085..fc2da81 100644
--- a/lxc/main.go
+++ b/lxc/main.go
@@ -155,29 +155,48 @@ type command interface {
}
var commands = map[string]command{
- "config": &configCmd{},
- "copy": ©Cmd{},
- "delete": &deleteCmd{},
- "exec": &execCmd{},
- "file": &fileCmd{},
- "finger": &fingerCmd{},
- "help": &helpCmd{},
- "image":&imageCmd{},
- "info": &infoCmd{},
- "init": &initCmd{},
- "launch": &launchCmd{},
- "list": &listCmd{},
- "monitor": &monitorCmd{},
- "move": &moveCmd{},
- "pause":&actionCmd{shared.Freeze, false, false, "pause", -1, false,
false, false},
+ "config": &configCmd{},
+ "copy":©Cmd{},
+ "delete": &deleteCmd{},
+ "exec":&execCmd{},
+ "file":&fileCmd{},
+ "finger": &fingerCmd{},
+ "help":&helpCmd{},
+ "image": &imageCmd{},
+ "info":&infoCmd{},
+ "init":&initCmd{},
+ "launch": &launchCmd{},
+ "list":&listCmd{},
+ "monitor": &monitorCmd{},
+ "move":&moveCmd{},
+ "pause": &actionCmd{
+ action: shared.Freeze,
+ name:"pause",
+ },
"profile": &profileCmd{},
"publish": &publishCmd{},
"remote": &remoteCmd{},
- "restart": &actionCmd{shared.Restart, true, true, "restart", -1,
false, false, false},
+ "restart": &actionCmd{
+ action: shared.Restart,
+ hasTimeout: true,
+ visible: true,
+ name: "restart",
+ timeout: -1,
+ },
"restore": &restoreCmd{},
"snapshot": &snapshotCmd{},
- "start":&actionCmd{shared.Start, false, true, "start", -1, false,
false, false},
- "stop": &actionCmd{shared.Stop, true, true, "stop", -1, false,
false, false},
+ "start":&actionCmd{
+ action: shared.Start,
+ visible: true,
+ name: "start",
+ },
+ "stop": &actionCmd{
+ action: shared.Stop,
+ hasTimeout: true,
+ visible: true,
+ name: "stop",
+ timeout: -1,
+ },
"version": &versionCmd{},
}
From 27ff38d0a670c867a59cf292d2ee241423ddbee7 Mon Sep 17 00:00:00 2001
From: Tycho Andersen
Date: Wed, 6 Jul 2016 16:27:09 -0600
Subject: [PATCH 2/2] add some additional help to `lxc pause`
Signed-off-by: Tycho Andersen
---
lxc/action.go | 23 ++-
lxc/main.go | 39 ---
2 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/lxc/action.go b/lxc/action.go
index 6858bc9..8fece38 100644
--- a/lxc/action.go
+++ b/lxc/action.go
@@ -10,14 +10,15 @@ import (
)
type actionCmd struct {
- action shared.ContainerAction
- hasTimeout bool
- visiblebool
- name string
- timeoutint
- force bool
- stateful bool
- stateless bool
+ action shared.ContainerAction
+ hasTimeout bool
+ visiblebool
+ name string
+ timeoutint
+ force bool
+ stateful bool
+ stateless bool
+ additionalHelp string
}
func (c *actionCmd) showByDefault() bool {
@@ -25,10 +26,14 @@ func (c *actionCmd) showByDefault() bool {
}
func (c *actionCmd) usage() string {
+ if c.additionalHelp != "" {
+ c.additionalHelp = fmt.Sprintf("\n\n%s", c.additionalHelp)
+ }
+
return fmt.Sprintf(i18n.G(
`Changes state of one or more containers to %s.
-lxc %s [...]`), c.name, c.name)
+lxc %s [...]%s`), c.name, c.name, c.additionalHelp)
}
func (c *actionCmd) flags() {
diff --git a/lxc/main.go b/lxc/main.go
index fc2da81..4938a0f 100644
--- a/lxc/main.go
+++ b/lxc/main.go
@@ -170,34 +170,35 @@ var commands = map[string]command{
"monitor": &monitorCmd{},
"move":&moveCmd{},
"pause": &actionCmd{
- action: shared.Freeze,
- name:"pause",
+ action: shared.Freeze,
+