Skip to content

Instantly share code, notes, and snippets.

@stan1y
Created May 27, 2017 23:38
Show Gist options
  • Select an option

  • Save stan1y/e207d0bc773fb8348f4c1b4b5466bad0 to your computer and use it in GitHub Desktop.

Select an option

Save stan1y/e207d0bc773fb8348f4c1b4b5466bad0 to your computer and use it in GitHub Desktop.
import optparse
import sys
def populate_with_regex(expr):
# return list of int ids
return [1, 2, 3]
def do_business_with_devices_list(lst):
print("business: %s" % repr(lst))
def main():
parser = optparse.OptionParser()
parser.add_option("--devices", action="append", type="int")
parser.add_option("--device-regex", type="string")
(options, args) = parser.parse_args()
if options.devices_regex:
options.devices = populate_with_regex(options.regex)
do_business_with_devices_list(options.devices)
if __name__ == '__main__':
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment