-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output options #28
base: master
Are you sure you want to change the base?
Output options #28
Conversation
Add the following options, both on the command line and in the config: --output_info: Where to output INFO messages: stdout|stderr --output_warn: Where to output WARN messages: stdout|stderr --output_error: Where to output ERROR messages: stdout|stderr --output_fatal: Where to output FATAL messages: stdout|stderr --wrap_long_lines: Wrap long lines of output, or output each message on a single line. --print_options: Print out effective config options, before starting.
raise OptionValueError( | ||
"option %s: invalid boolean value: %r" % (opt, value)) | ||
|
||
class MyOption (Option): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Just use store_true
or store_false
https://docs.python.org/2/library/optparse.html#handling-boolean-flag-options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I did originally, but that doesn't work the way I expected: it forces you to have two parameters. So instead of looking like this:
--wrap_long_lines=True
--wrap_long_lines=False
it would turn into two options, like this:
--wrap_long_lines_on
--wrap_long_lines_off
If you'd rather do it that way, I can change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming it defaults to False, it should just be
parser.add_option('--wrap_long_lines', dest='wrap_long_lines', action="store_true", default=False,
help="Wrap long lines of output, or output each message on a single line.")
def error(message, file=sys.stderr): | ||
def error(message, settings, file=None): | ||
if file is None: | ||
file = getattr(sys, settings.output_error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to this much effort, should we support actual files too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe?
I'm post processing the output (#22) to turn it into a checklist - which was why I added the wrap_long_lines
parameter. But I'm OK with ansible-review outputting to stdout, so the output can be feed to wherever.
I just added these lines so I could (optionally) have all the output go to stdout
without having to bash redirecting it using 2>&1
or &>
, because that was garbling it (stderr
output in the middle of stdout
lines, occasionally).
Maybe we could expand this to support outputting to regular files later?
Add & implement the following options, both on the command line and in the config:
This option is only supported on the command line, and it intended for debugging/figuring out if your config settings are being picked up:
If you don't set any of these, the behaviour is as before.