Skip to content

Output options - #28

Open
dflock wants to merge 6 commits into
willthames:masterfrom
phemisystems:output_options
Open

Output options#28
dflock wants to merge 6 commits into
willthames:masterfrom
phemisystems:output_options

Conversation

@dflock

@dflock dflock commented May 10, 2017

Copy link
Copy Markdown
Contributor

Add & implement 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.

This option is only supported on the command line, and it intended for debugging/figuring out if your config settings are being picked up:

--print_options: Print out effective config options, before starting.

If you don't set any of these, the behaviour is as before.

Duncan Lock added 4 commits May 9, 2017 18:18
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):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

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.

@willthames willthames Aug 2, 2017

Copy link
Copy Markdown
Owner

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)

Copy link
Copy Markdown
Owner

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?

Copy link
Copy Markdown
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants