Skip to content

Commit

Permalink
Use ConfigArgParse to support config files
Browse files Browse the repository at this point in the history
Need to resurrect fast poll, include/exclude, and others of that ilk.
  • Loading branch information
davesteele authored and armooo committed Jan 18, 2017
1 parent de4b914 commit 326ce76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 14 additions & 11 deletions cloudprint/cloudprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from __future__ import absolute_import
from __future__ import print_function

import argparse
import configargparse
import cups
import datetime
import hashlib
Expand Down Expand Up @@ -465,63 +465,66 @@ def process_jobs_once(cups_connection, cpp, xmpp_conn):


def parse_args():
parser = argparse.ArgumentParser()
parser = configargparse.ArgParser(
default_config_files=['/etc/cloudprint.conf',
'~/.cloudprint.conf'],
)
parser.add_argument(
'-d',
'-d', '--daemon',
dest='daemon',
action='store_true',
help='enable daemon mode (requires the daemon module)',
)
parser.add_argument(
'-l',
'-l', '--logout',
dest='logout',
action='store_true',
help='logout of the google account',
)
parser.add_argument(
'-p',
'-p', '--pidfile',
metavar='pid_file',
dest='pidfile',
default='cloudprint.pid',
help='path to write the pid to (default %(default)s)',
)
parser.add_argument(
'-a',
'-a', '--account_file',
metavar='account_file',
dest='authfile',
default=os.path.expanduser('~/.cloudprintauth.json'),
help='path to google account ident data (default %(default)s)',
)
parser.add_argument(
'-c',
'-c', '--credentials',
dest='authonly',
action='store_true',
help='establish and store login credentials, then exit',
)
parser.add_argument(
'-f',
'-f', '--fastpoll',
dest='fastpoll',
action='store_true',
help='use fast poll if notifications are not working',
)
parser.add_argument(
'-i',
'-i', '--include',
metavar='regexp',
dest='include',
default=[],
action='append',
help='include local printers matching %(metavar)s',
)
parser.add_argument(
'-x',
'-x', '--exclude',
metavar='regexp',
dest='exclude',
default=[],
action='append',
help='exclude local printers matching %(metavar)s',
)
parser.add_argument(
'-v',
'-v', '--verbose',
dest='verbose',
action='store_true',
help='verbose logging',
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
},
install_requires=[
'argparse',
'configargparse',
'pycups',
'requests >= 2.7.0',
],
Expand Down

0 comments on commit 326ce76

Please sign in to comment.