def cli(ctx, email, password, account, environment):
cookiejar = os.path.expanduser('~/.config/neres/{}.cookies'.format(environment))
if not os.path.exists(os.path.dirname(cookiejar)):
os.makedirs(os.path.dirname(cookiejar), 0o700)
newrelic.initialize_cookiejar(cookiejar)
if ctx.invoked_subcommand != 'login':
with Spinner('Authorizing: '):
if all([email, password]):
newrelic.login(email, password)
else:
if not newrelic.check_if_logged_in():
raise click.ClickException('Login first')
if not account and ctx.invoked_subcommand != 'list-accounts':
account = newrelic.get_accounts()[0]['id']
ctx.obj = {}
ctx.obj['ACCOUNT'] = account
ctx.obj['EMAIL'] = email
ctx.obj['PASSWORD'] = password
评论列表
文章目录