本文整理汇总了Python中argh.ArghParser.add_argument方法的典型用法代码示例。如果您正苦于以下问题:Python ArghParser.add_argument方法的具体用法?Python ArghParser.add_argument怎么用?Python ArghParser.add_argument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类argh.ArghParser
的用法示例。
在下文中一共展示了ArghParser.add_argument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
parser = ArghParser()
parser.add_commands(
(
module_list,
module_install,
module_uninstall,
module_enable,
module_disable
),
namespace='module',
title='Module commands',
description='Group of commands related to listing or (un)installing modules'
)
ini_file='production.ini'
if 'NP_INI_FILE' in os.environ:
ini_file = os.environ['NP_INI_FILE']
ini_name='netprofile'
if 'NP_INI_NAME' in os.environ:
ini_name = os.environ['NP_INI_NAME']
parser.add_argument('--ini-file', '-i', default=ini_file, help='Specify .ini file to use')
parser.add_argument('--application', '-a', default=ini_name, help='Default app section of .ini file to use')
parser.dispatch()
示例2: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
l18n.init()
parser = ArghParser()
parser.add_argument('-a', '--auth',
action='store_true',
help=_('Authenticate and show all problems'
' on this machine'))
parser.add_argument('-v', '--version',
action='version',
version=config.VERSION)
parser.add_commands([
backtrace,
di_install,
gdb,
info,
list_problems,
remove,
report,
retrace,
status,
])
argcomplete.autocomplete(parser)
try:
parser.dispatch()
except KeyboardInterrupt:
sys.exit(1)
sys.exit(0)
示例3: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
reload(sys)
sys.setdefaultencoding("utf-8")
parser = ArghParser(description='Simple static gallery generator.')
parser.add_commands([init, build, serve])
parser.add_argument('--version', action='version',
version='%(prog)s {}'.format(__version__))
parser.dispatch()
示例4: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
"""
Main entrypoint for console_script (commandline script)
"""
parser = ArghParser()
parser.add_argument('-v', '--version', action='version', version=client_version)
enabled_commands = [pull, push]
parser.add_commands(enabled_commands)
parser.dispatch()
示例5: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
"""
Main entrypoint for console_script (commandline script)
"""
parser = ArghParser()
parser.add_argument("-v", "--version", action="version", version=client_version)
enabled_commands = [register]
parser.add_commands(enabled_commands)
parser.dispatch()
示例6: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
commands = pack, watch, shell, libs
names = [f.__name__ for f in commands] + [ 'help' ]
parser = ArghParser()
parser.add_argument('-v', '--version', action='version', version=VERSION, help='Show zeta version')
parser.add_commands(commands)
argv = sys.argv[1:]
if argv and not argv[0] in names and not argv[0] in ['-v', '--version']:
argv.insert(0, 'pack')
parser.dispatch(argv)
示例7: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
"""
The main method of Barman
"""
p = ArghParser(epilog='Barman by 2ndQuadrant (www.2ndQuadrant.com)')
p.add_argument('-v', '--version', action='version',
version='%s\n\nBarman by 2ndQuadrant (www.2ndQuadrant.com)'
% barman.__version__)
p.add_argument('-c', '--config',
help='uses a configuration file '
'(defaults: %s)'
% ', '.join(barman.config.Config.CONFIG_FILES),
default=SUPPRESS)
p.add_argument('-q', '--quiet', help='be quiet', action='store_true')
p.add_argument('-d', '--debug', help='debug output', action='store_true')
p.add_argument('-f', '--format', help='output format',
choices=output.AVAILABLE_WRITERS.keys(),
default=output.DEFAULT_WRITER)
p.add_commands(
[
archive_wal,
backup,
check,
cron,
delete,
diagnose,
get_wal,
list_backup,
list_files,
list_server,
rebuild_xlogdb,
receive_wal,
recover,
show_backup,
show_server,
replication_status,
status,
switch_xlog,
]
)
# noinspection PyBroadException
try:
p.dispatch(pre_call=global_config)
except KeyboardInterrupt:
msg = "Process interrupted by user (KeyboardInterrupt)"
output.error(msg)
except Exception as e:
msg = "%s\nSee log file for more details." % e
output.exception(msg)
# cleanup output API and exit honoring output.error_occurred and
# output.error_exit_code
output.close_and_exit()
示例8: get_base_parser
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def get_base_parser():
dist = pkg_resources.get_distribution("awstools")
parser = ArghParser(version=dist.version)
parser.add_argument(
'--config',
default=None,
help="path of an alternative configuration file")
parser.add_argument(
'--settings',
default=None,
help="path of the application settings configuration file")
return parser
示例9: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
"""
The main method of Barman
"""
p = ArghParser()
p.add_argument("-v", "--version", action="version", version=barman.__version__)
p.add_argument(
"-c",
"--config",
help="uses a configuration file " "(defaults: %s)" % ", ".join(barman.config.Config.CONFIG_FILES),
default=SUPPRESS,
)
p.add_argument("-q", "--quiet", help="be quiet", action="store_true")
p.add_argument("-d", "--debug", help="debug output", action="store_true")
p.add_argument(
"-f", "--format", help="output format", choices=output.AVAILABLE_WRITERS.keys(), default=output.DEFAULT_WRITER
)
p.add_commands(
[
archive_wal,
backup,
check,
cron,
delete,
diagnose,
get_wal,
list_backup,
list_files,
list_server,
rebuild_xlogdb,
receive_wal,
recover,
show_backup,
show_server,
status,
]
)
# noinspection PyBroadException
try:
p.dispatch(pre_call=global_config)
except KeyboardInterrupt:
msg = "Process interrupted by user (KeyboardInterrupt)"
output.exception(msg)
except Exception, e:
msg = "%s\nSee log file for more details." % e
output.exception(msg)
示例10: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
"""
The main method of Barman
"""
p = ArghParser()
p.add_argument('-v', '--version', action='version',
version=barman.__version__)
p.add_argument('-c', '--config',
help='uses a configuration file '
'(defaults: %s)'
% ', '.join(barman.config.Config.CONFIG_FILES),
default=SUPPRESS)
p.add_argument('-q', '--quiet', help='be quiet', action='store_true')
p.add_argument('-d', '--debug', help='debug output', action='store_true')
p.add_argument('-f', '--format', help='output format',
choices=output.AVAILABLE_WRITERS.keys(),
default=output.DEFAULT_WRITER)
p.add_commands(
[
archive_wal,
cron,
list_server,
show_server,
status,
check,
diagnose,
backup,
list_backup,
show_backup,
list_files,
get_wal,
recover,
delete,
rebuild_xlogdb,
]
)
# noinspection PyBroadException
try:
p.dispatch(pre_call=global_config)
except KeyboardInterrupt:
msg = "Process interrupted by user (KeyboardInterrupt)"
output.exception(msg)
except Exception, e:
msg = "%s\nSee log file for more details." % e
output.exception(msg)
示例11: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
l18n.init()
parser = ArghParser()
parser.add_argument(
"-a", "--auth", action="store_true", help=_("Authenticate and show all problems" " on this machine")
)
parser.add_argument("-v", "--version", action="version", version=config.VERSION)
parser.add_commands([backtrace, di_install, gdb, info, list_problems, remove, report, retrace, status])
argcomplete.autocomplete(parser)
try:
parser.dispatch()
except KeyboardInterrupt:
sys.exit(1)
sys.exit(0)
示例12: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main():
''' The main method of Barman '''
p = ArghParser()
p.add_argument('-v', '--version', action='version', version=barman.__version__)
p.add_argument('-c', '--config', help='uses a configuration file (defaults: $HOME/.barman.conf, /etc/barman.conf)')
p.add_argument('-q', '--quiet', help='be quiet', action='store_true')
p.add_commands(
[
cron,
list_server,
show_server,
status,
check,
backup,
list_backup,
show_backup,
list_files,
recover,
delete,
]
)
try:
p.dispatch(pre_call=global_config, output_file=_output_stream)
except Exception:
msg = "ERROR: Unhandled exception. See log file for more details."
logging.exception(msg)
raise SystemExit(msg)
示例13: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
def main(): # pragma: no cover
'''Console entry point.
Constructs and dispatches the argument parser.
'''
parser = ArghParser(prog='pageit', description=pageit.__doc__,
epilog=pageit.__epilog__)
parser.add_argument('--version', action='version',
version='%(prog)s ' + pageit.__version__)
parser.add_argument('-v', '--verbose', dest='verbosity', action='count',
default=1, help='show logging messages')
parser.add_argument('-q', '--quiet', dest='verbosity',
action='store_const', const=0,
help='suppress logging messages')
parser.set_default_command(render)
parser.dispatch()
示例14: ArghParser
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
from __future__ import print_function
import json
import logging
from argh import ArghParser
from ghtools import cli
from ghtools.github.repo import Repo
log = logging.getLogger(__name__)
parser = ArghParser(description="Interact with GitHub repos")
parser.add_argument("repo", help="Repo identifier, e.g. defunkt/resque, enterprise:mycorp/myproj")
def delete(args):
"""
Delete the specified repository
"""
repo = Repo(args.repo)
with cli.catch_api_errors():
repo.delete()
parser.add_commands([delete])
def get(args):
"""
Print the JSON representation of the specified repository to STDOUT
"""
示例15: Observer
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import add_argument [as 别名]
handler.start()
observer = Observer(timeout=args.timeout)
observe_with(observer, handler, args.directories, args.recursive)
handler.stop()
epilog = """Copyright 2011 Yesudeep Mangalapilly <[email protected]>.
Copyright 2012 Google, Inc.
Licensed under the terms of the Apache license, version 2.0. Please see
LICENSE in the source code for more information."""
parser = ArghParser(epilog=epilog)
parser.add_commands([tricks_from,
tricks_generate_yaml,
log,
shell_command,
auto_restart])
parser.add_argument('--version',
action='version',
version='%(prog)s ' + VERSION_STRING)
def main():
"""Entry-point function."""
parser.dispatch()
if __name__ == '__main__':
main()