Merge lp:~thumper/juju-core/default-command-info into lp:~go-bot/juju-core/trunk
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2479 |
Proposed branch: | lp:~thumper/juju-core/default-command-info |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
323 lines (+152/-39) 6 files modified
cmd/cmd.go (+34/-4) cmd/juju/deploy.go (+2/-3) cmd/juju/deploy_test.go (+2/-2) cmd/juju/main_test.go (+1/-0) cmd/logging.go (+25/-18) cmd/logging_test.go (+88/-12) |
To merge this branch: | bzr merge lp:~thumper/juju-core/default-command-info |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+194061@code.launchpad.net |
Commit message
Add standard functions for command output.
Add simple function support and flags around changing how the command output
works by default. Add flag options for '-q' and '--quiet'. Also updated the text for the flags.
There are now two methods on the cmd.Context object that should be used for output:
func (ctx *Context) Infof(format string, params ...interface{})
and
func (ctx *Context) Verbosef(format string, params ...interface{})
If quiet is specified, both are logged instead of written out. If verbose is
specified, both are written out, if the defaults are used, Info is written
out, but verbose is logged.
Description of the change
Add standard functions for command output.
Add simple function support and flags around changing how the command output
works by default. Add flag options for '-q' and '--quiet', and provider a
short '-d' for '--debug'. Also updated the text for the flags.
There are now two methods in the cmd package that should be used for output:
cmd.Infof(...)
and
cmd.Verbosef(...)
If quiet is specified, both are logged instead of written out. If verbose is
specified, both are written out, if the defaults are used, Info is written
out, but verbose is logged.
Ideally I'd like to tweak loggo so we can specify the call depth of the
caller, so we can grab the appropriate line numbers etc, but this can happen
later. Also, now any use of these methods will have the 'juju.cmd' module. Not
sure if we want to really parameterize that.
The only thing I'm wondering about is Stderr vs. Stdout. Ideally I'd prefer
to use Stdout where possible, but for the format oriented commands, we still
want users to be able to go:
'juju status --format=json | other-thing'
So we don't want to polute Stdout in those situations with output.
There are a number of options here:
* we just write to Stdout, and have people add '-q'
* we write the info and verbose info to Stderr so it just works
Then do we have some go to Stdout and some Stderr?
Logging now goes to Stderr, so we could just send all output there (except for
the actual formatted output).
Reviewers: mp+194061_ code.launchpad. net,
Message:
Please take a look.
Description:
Add standard functions for command output.
Add simple function support and flags around changing how the command
output
works by default. Add flag options for '-q' and '--quiet', and provider
a
short '-d' for '--debug'. Also updated the text for the flags.
There are now two methods in the cmd package that should be used for Verbosef( ...)
output:
cmd.Infof(...)
and
cmd.
If quiet is specified, both are logged instead of written out. If
verbose is
specified, both are written out, if the defaults are used, Info is
written
out, but verbose is logged.
Ideally I'd like to tweak loggo so we can specify the call depth of the
caller, so we can grab the appropriate line numbers etc, but this can
happen
later. Also, now any use of these methods will have the 'juju.cmd'
module. Not
sure if we want to really parameterize that.
The only thing I'm wondering about is Stderr vs. Stdout. Ideally I'd
prefer
to use Stdout where possible, but for the format oriented commands, we
still
want users to be able to go:
'juju status --format=json | other-thing'
So we don't want to polute Stdout in those situations with output.
There are a number of options here:
* we just write to Stdout, and have people add '-q'
* we write the info and verbose info to Stderr so it just works
Then do we have some go to Stdout and some Stderr?
Logging now goes to Stderr, so we could just send all output there
(except for
the actual formatted output).
https:/ /code.launchpad .net/~thumper/ juju-core/ default- command- info/+merge/ 194061
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/22320043/
Affected files (+139, -28 lines):
A [revision details]
M cmd/export_test.go
M cmd/logging.go
M cmd/logging_test.go