Skip to content

Instantly share code, notes, and snippets.

@s-boardman
Forked from kmanalo/argparse.gist
Last active August 29, 2015 14:15
Show Gist options
  • Save s-boardman/efe57366f8bd040e3c39 to your computer and use it in GitHub Desktop.
Save s-boardman/efe57366f8bd040e3c39 to your computer and use it in GitHub Desktop.

Revisions

  1. s-boardman revised this gist Jul 1, 2015. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions argparse.gist
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,13 @@
    # argparse section
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("-e","--email", help="send to specific email")
    parser.add_argument("-c","--console", action="store_true", default=False, help="push results to stdout")
    parser.add_argument("-l","--list", help="pass a list", nargs="*")
    parser.add_argument("-b","--boolean", action="store_true", default=False, help="use this flag to turn on an option")


    # grab the options here from the command line, console overrides email
    args = parser.parse_args()
    args = parser.parse_args()

    list = args.list
    if args.boolean is True:
    boolean = True
  2. s-boardman revised this gist Feb 10, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions argparse.gist
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # argparse section
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("--email", help="send to specific email")
    parser.add_argument("--console", action="store_true", default=False, help="push results to stdout")
    parser.add_argument("-e","--email", help="send to specific email")
    parser.add_argument("-c","--console", action="store_true", default=False, help="push results to stdout")
    # grab the options here from the command line, console overrides email
    args = parser.parse_args()
  3. @kmanalo kmanalo created this gist Nov 12, 2014.
    7 changes: 7 additions & 0 deletions argparse.gist
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # argparse section
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("--email", help="send to specific email")
    parser.add_argument("--console", action="store_true", default=False, help="push results to stdout")
    # grab the options here from the command line, console overrides email
    args = parser.parse_args()