-
Notifications
You must be signed in to change notification settings - Fork 31
/
app_args.py
57 lines (46 loc) · 1.87 KB
/
app_args.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# provides app argument parsing values
__all__ = ['get_options']
from argparse import ArgumentParser
parser = ArgumentParser(description=__doc__)
add_argument = parser.add_argument
def get_app_args():
"""Returns the application arguments from stdin
@return Object optparse.Values or argparse.Namespace
"""
arguments = parser.parse_args()
if isinstance(arguments, tuple):
# assume its optparse return value
(opts, args) = arguments
return opts
return arguments
def add_app_args():
"""Add app arguments"""
add_argument('-r', '--runserver', dest='run_server',
action='store_true',
help='Run the Sherlock web server.')
add_argument('-c', '--config', dest='config',
action='store',
help='Sherlock config settings absolute path.')
add_argument('-v', '--version', dest='show_version',
action='store_true',
help='Show sherlock version information.')
# TODO: not available, yet
# add_argument('-q', '--quiet',
# action='store_false', dest='verbose', default=True,
# help='Don\'t print status messages to stdout.')
add_argument('--test', dest='run_tests',
action='store_true',
help='Run tests to ensure everything works correctly.')
add_argument('--stats', dest='show_stats',
action='store_true',
help='Show sherlock statistics.')
add_argument('--index', dest='reindex',
action='store',
help=('Indexes the in the path specified by '
'settings.INDEX_PATHS. Use `update` or '
'`rebuild` to replace the entire index.'))
add_app_args()
def get_options():
""" Returns the options from the script """
options = get_app_args()
return options