Skip to content

Commit 8f0624e

Browse files
committed
Display globally available 'juju' command options for all sub-commands.
1 parent de08724 commit 8f0624e

File tree

8 files changed

+36
-8
lines changed

8 files changed

+36
-8
lines changed

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287

288288
[[constraint]]
289289
name = "github.com/juju/cmd"
290-
revision = "fd568e4a4120f7d5a417252d701daff61a6322b4"
290+
revision = "a8c88215d37e4d65036822bca0522d11f888f7eb"
291291

292292
[[constraint]]
293293
name = "github.com/juju/collections"

cmd/juju/commands/helptool_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ func (suite *HelpToolSuite) TestHelpToolHelp(c *gc.C) {
2626
Summary:
2727
Show help on a Juju charm hook tool.
2828
29+
Global Options:
30+
--debug (= false)
31+
equivalent to --show-log --logging-config=<root>=DEBUG
32+
-h, --help (= false)
33+
Show help on a command or other topic.
34+
--logging-config (= "")
35+
specify log levels for modules
36+
--quiet (= false)
37+
show no informational output
38+
--show-log (= false)
39+
if set, write the log file to stderr
40+
--verbose (= false)
41+
show more verbose output
42+
2943
Details:
3044
Juju charms can access a series of built-in helpers called 'hook-tools'.
3145
These are useful for the charm to be able to inspect its running environment.

cmd/juju/commands/main_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/juju/version"
2626
gc "gopkg.in/check.v1"
2727

28+
jujucmd "github.com/juju/juju/cmd"
2829
"github.com/juju/juju/cmd/juju/application"
2930
"github.com/juju/juju/cmd/juju/cloud"
3031
"github.com/juju/juju/cmd/modelcmd"
@@ -48,7 +49,15 @@ func helpText(command cmd.Command, name string) string {
4849
info.Name = name
4950
f := gnuflag.NewFlagSetWithFlagKnownAs(info.Name, gnuflag.ContinueOnError, cmd.FlagAlias(command, "option"))
5051
command.SetFlags(f)
51-
buff.Write(info.Help(f))
52+
53+
superJuju := jujucmd.NewSuperCommand(cmd.SuperCommandParams{
54+
Name: "juju",
55+
FlagKnownAs: "option",
56+
})
57+
superF := gnuflag.NewFlagSetWithFlagKnownAs("juju", gnuflag.ContinueOnError, "option")
58+
superJuju.SetFlags(superF)
59+
60+
buff.Write(info.HelpWithSuperFlags(superF, f))
5261
return buff.String()
5362
}
5463

cmd/juju/resource/charmresources_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ For cs:~user/trusty/mysql
5858
Where the series is not supplied, the series from your local host is used.
5959
Thus the above examples imply that the local series is trusty.
6060
`,
61-
FlagKnownAs: "option",
61+
FlagKnownAs: "option",
62+
ShowSuperFlags: []string{"show-log", "debug", "logging-config", "verbose", "quiet", "h", "help"},
6263
})
6364
}
6465

cmd/juju/resource/list_charm_resources_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ For cs:~user/trusty/mysql
5858
Where the series is not supplied, the series from your local host is used.
5959
Thus the above examples imply that the local series is trusty.
6060
`,
61-
Aliases: []string{"list-resources"},
62-
FlagKnownAs: "option",
61+
Aliases: []string{"list-resources"},
62+
FlagKnownAs: "option",
63+
ShowSuperFlags: []string{"show-log", "debug", "logging-config", "verbose", "quiet", "h", "help"},
6364
})
6465
}
6566

cmd/juju/resource/list_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ This command shows the resources required by and those in use by an existing
7171
application or unit in your model. When run for an application, it will also show any
7272
updates available for resources from the charmstore.
7373
`,
74-
FlagKnownAs: "option",
74+
FlagKnownAs: "option",
75+
ShowSuperFlags: []string{"show-log", "debug", "logging-config", "verbose", "quiet", "h", "help"},
7576
})
7677
}
7778

cmd/juju/resource/upload_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ func (s *UploadSuite) TestInfo(c *gc.C) {
9797
This command uploads a file from your local disk to the juju controller to be
9898
used as a resource for an application.
9999
`,
100-
Aliases: []string{"attach"},
101-
FlagKnownAs: "option",
100+
Aliases: []string{"attach"},
101+
FlagKnownAs: "option",
102+
ShowSuperFlags: []string{"show-log", "debug", "logging-config", "verbose", "quiet", "h", "help"},
102103
})
103104
}
104105

cmd/supercommand.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ func runNotifier(name string) {
6161
func Info(i *cmd.Info) *cmd.Info {
6262
info := *i
6363
info.FlagKnownAs = "option"
64+
info.ShowSuperFlags = []string{"show-log", "debug", "logging-config", "verbose", "quiet", "h", "help"}
6465
return &info
6566
}

0 commit comments

Comments
 (0)