本文整理汇总了Python中argh.ArghParser.set_default_command方法的典型用法代码示例。如果您正苦于以下问题:Python ArghParser.set_default_command方法的具体用法?Python ArghParser.set_default_command怎么用?Python ArghParser.set_default_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类argh.ArghParser
的用法示例。
在下文中一共展示了ArghParser.set_default_command方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eventparser_entry
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import set_default_command [as 别名]
def eventparser_entry():
parser = ArghParser(parents=[COMMON_PARSER])
parser.set_default_command(eventparser)
completion.autocomplete(parser)
# Parse ahead
args = parser.parse_args()
if args.debug:
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)s: %(message)s'
)
parser.dispatch()
示例2: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import set_default_command [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()
示例3: zsmc_main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import set_default_command [as 别名]
def zsmc_main():
parser = ArghParser(formatter_class=argparse.RawDescriptionHelpFormatter)
parser.set_default_command(start)
parser.dispatch()
示例4: _raw_input
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import set_default_command [as 别名]
username = _raw_input("Username: ")
password = getpass("Password: ")
gh.login(username, password, scopes=scopes, comment=comment)
@arg("-s", "--scope", default=None, action="append", help="GitHub auth scopes to request")
@arg("-c", "--comment", help="Comment to attach to the auth token request")
@arg("github", nargs="?", help='GitHub instance nickname (e.g "enterprise")')
def login(args):
"""
Log into a GitHub instance, and print the resulting OAuth token.
"""
with cli.catch_api_errors():
client = GithubAPIClient(nickname=args.github)
login_if_needed(client, args.scope, comment=args.comment)
oauth_token_key = envkey(client.nickname, "oauth_token")
print("export {0}='{1}'".format(oauth_token_key, client.token))
parser.set_default_command(login)
def main():
parser.dispatch()
if __name__ == "__main__":
main()
示例5: command
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import set_default_command [as 别名]
def command():
# http://argh.readthedocs.org/en/latest/
parser = ArghParser(description=__doc__)
parser.set_default_command(reorder_po)
parser.dispatch()
示例6: status
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import set_default_command [as 别名]
@arg('-c', '--context', help='Label to differentiate this status from the status of other systems')
def status(args):
"""
Set build status for a commit on GitHub
"""
repo = Repo(args.repo)
payload = {'state': args.state}
if args.description is not None:
payload['description'] = args.description
if args.url is not None:
payload['target_url'] = args.url
if args.context is not None:
payload['context'] = args.context
with cli.catch_api_errors():
res = repo.set_build_status(args.sha, payload)
print(json.dumps(res.json(), indent=2))
parser.set_default_command(status)
def main():
parser.dispatch()
if __name__ == '__main__':
main()
示例7: main
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import set_default_command [as 别名]
def main():
p = ArghParser()
p.set_default_command(remux)
p.dispatch()
示例8: nickname
# 需要导入模块: from argh import ArghParser [as 别名]
# 或者: from argh.ArghParser import set_default_command [as 别名]
@arg('github', nargs='?', help='GitHub instance nickname (e.g "enterprise")')
@arg('url', help='URL to browse')
@arg('-m', '--method', default='get', choices=('get', 'delete'), help='HTTP method to use.')
def browse(args):
"""
Print the GitHub API response at the given URL
"""
with cli.catch_api_errors():
client = GithubAPIClient(nickname=args.github)
res = client.request(args.method, args.url, _raise=False)
print('HTTP/1.1 {0} {1}'.format(res.status_code, res.reason))
for k, v in res.headers.items():
print("{0}: {1}".format(k, v))
print()
if res.json() is not None:
print(json.dumps(res.json(), indent=2))
else:
print(res.content)
parser.set_default_command(browse)
def main():
parser.dispatch()
if __name__ == '__main__':
main()