Skip to content

Conversation

@MartinBasti
Copy link
Contributor

  • also show traceback in debug mode

Signed-off-by: Martin Bašti mbasti@redhat.com

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 29, 2019
Copy link
Contributor Author

@MartinBasti MartinBasti left a comment

Choose a reason for hiding this comment

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

Current implementation doesn't support global options because only first arg is passed to main cli parser.

'CRITICAL'],
default='WARNING', type=str.upper)

args = parser.parse_args(sys.argv[1:2])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is not working due this line. Because PR with argparse subparsers was rejected, I'm waiting for suggestion how to update this.

Copy link
Member

Choose a reason for hiding this comment

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

@MartinBasti

Two comments here:

  1. I'm still not sure I see why not using subparsers is preventing a top level flag like this. Why can't we just explicitly parse this command in this method? We aren't throwing anything away.

  2. The PR that included a move to subparsers wasn't rejected because it used subparsers. It was rejected because the PR was attempting to address two unrelated things (adding subparsers and attempting to resolve this issue: document --ui_validate_io switch #77). I just stated that moving to subparsers didn't fix that issue, and either the PR should have been updated to fix that issue and explain why adding subparser use was needed to resolve it OR stop referencing that issue and instead just add subparsers and in a detailed way explain why that was useful. Instead of following up on my point, the PR was just closed.

I am not against using subparsers, I just believe that git history should be concise and clean and that every PR should have a singular stated purpose. If you strongly believe that the best way to implement this feature is to include the use of subparsers then feel free to either reopen the other PR with what I was requesting, or feel free to include that change in this PR if you feel it is necessary for this change. But when you do, please clearly state why that is the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • main parser uses only first argument sys.argv[1:2]
  • command parsers uses second+ argument for parsing sys.argv[2:]
  • when I use --log-level on first position I got error that subcommand is required
  • when I use subcommand on first position, log-level is just ignored
  • because log-level is optional, I cannot hardcode sys.argv[3:]
  • I'm not gonna copy that option to each command parser
  • subparsers handles this even without thinking about that some sys.argv[] exists
  1. I will reopen it then

@MartinBasti
Copy link
Contributor Author

MartinBasti commented Mar 29, 2019

Reason for this PR was in #85 (comment) as it was not nice to find which part of code failed from CLI output

action='version', version=__version__)
parser.add_argument('--log-level', dest='log_level',
help="Set logging level (default: WARNING)",
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR',
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to allow all of these options? Why not just allow DEBUG and INFO? By default we will already log the others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is wrong about having all of them? when I don't care about WARNINGs I can enable only errors.

I can use --verbose or --debug to enable DEBUG level, if you insist

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer -v and --verbose to enable DEBUG from the command line since this is a much more common convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

-v is already used

I will rework that to --verbose

@MartinBasti MartinBasti changed the title Allow log-level configuration from CLI CLI: Add --verbose mode option Apr 4, 2019
Enables logging at DEBUG level

* also show traceback as debug log

Signed-off-by: Martin Bašti <mbasti@redhat.com>
@MartinBasti
Copy link
Contributor Author

Ready for review

@kevinrizza
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 4, 2019
@MartinBasti
Copy link
Contributor Author

Is there anything blocking this PR from merging?

Copy link
Member

@jeremy-wl jeremy-wl left a comment

Choose a reason for hiding this comment

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

/lgtm

@kevinrizza
Copy link
Member

Is there anything blocking this PR from merging?

Was waiting on one more set of eyes. Thanks @JEREMYLINLIN

@kevinrizza kevinrizza merged commit bba1add into operator-framework:master Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants