Testing argparse partial parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function, absolute_import, division | |
def run(options, script_args): | |
print('options', options, 'script_args', script_args) | |
if '__main__' == __name__: | |
import argparse | |
parser = argparse.ArgumentParser(description="Argparse Test Script") | |
parser.add_argument("-s", "--steal-output", action="store_true"), | |
parser.add_argument("-m", "--module", metavar="MODULE", | |
help="Debug module or package instead of script"), | |
parser.add_argument("--pre-run", metavar="COMMAND", | |
help="Run command before each program run", | |
default="") | |
parser.add_argument('args', nargs=argparse.REMAINDER) | |
options, script_args = parser.parse_known_args() | |
run(options, script_args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment