Skip to content
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

Add default known_only to parse_flags_with_usage #120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions absl/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,21 @@ def parse(self, arg):
sys.exit(1)


def parse_flags_with_usage(args):
def parse_flags_with_usage(args, known_only=False):
"""Tries to parse the flags, print usage, and exit if unparseable.

Args:
args: [str], a non-empty list of the command line arguments including
program name.
known_only: bool, if True, parse and remove known flags; return the rest
untouched. Unknown flags specified by --undefok are not returned.

Returns:
[str], a non-empty list of remaining command line arguments after parsing
flags, including program name.
"""
try:
return FLAGS(args)
return FLAGS(args, known_only=known_only)
except flags.Error as error:
sys.stderr.write('FATAL Flags parsing error: %s\n' % error)
sys.stderr.write('Pass --helpshort or --helpfull to see help on flags.\n')
Expand Down