def login(url, username, password, update_apidoc, display_meta):
s = requests.Session()
r = s.post('{}/api/rest/auth/login'.format(url),
json={'username': username, 'password': password})
rest = r.json()
if rest['status'] == 'login.failed':
click.secho('Fail to login, wrong username or password!', fg='red')
return
headers = {item: rest[item]
for item in ('token', 'apiToken', 'apiLicenseToken')}
s.headers = headers
if update_apidoc:
update_completions(s, url)
click.echo('Syntax: <command> [params] [options]')
click.echo('Press `Ctrl+D` to exit')
history = InMemoryHistory()
history.append('scm apiname')
history.append('help apiname')
while True:
try:
text = prompt(get_prompt_tokens=get_prompt_tokens,
completer=SCMCompleter(TextUtils(display_meta)),
auto_suggest=AutoSuggestFromHistory(),
style=DocumentStyle,
history=history,
on_abort=AbortAction.RETRY)
except EOFError:
break
process_command(s, url, text)
评论列表
文章目录