30 lines
725 B
Python
30 lines
725 B
Python
|
from __future__ import print_function
|
||
|
|
||
|
import sys
|
||
|
from os.path import basename
|
||
|
|
||
|
|
||
|
__meta__ = dict(
|
||
|
name='flickrscripts',
|
||
|
version='0.1.0',
|
||
|
entry_points={
|
||
|
'console_scripts': [
|
||
|
'flickrscripts = flickrscripts:route',
|
||
|
],
|
||
|
},
|
||
|
)
|
||
|
USAGE = 'Usage: {prog} <subcommand> [args]'
|
||
|
|
||
|
|
||
|
def route(sysargs=sys.argv[:]):
|
||
|
try:
|
||
|
subcommand = sysargs.pop(1)
|
||
|
import_name = 'flickrscripts.{}'.format(subcommand)
|
||
|
|
||
|
module = __import__(import_name, fromlist=[import_name])
|
||
|
return module.main(sysargs)
|
||
|
except IndexError:
|
||
|
print(USAGE.format(prog=basename(sysargs[0])), file=sys.stderr)
|
||
|
print('You must provide a subcommand', file=sys.stderr)
|
||
|
return 1
|