Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit 3ec7c76

Browse files
committed
Add optional prompt for apiKey
1 parent f1b6b99 commit 3ec7c76

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

paperspace/cli/auth.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import click
22

33
from paperspace import client, config
4+
from paperspace.cli import common
45
from paperspace.cli.cli import cli
56
from paperspace.cli.validators import validate_email
67
from paperspace.commands import login as login_commands
@@ -39,7 +40,7 @@ def logout():
3940

4041

4142
@cli.command("apiKey", help="Save your api key")
42-
@click.argument("api_key")
43+
@click.argument("api_key", required=False, callback=common.prompt_for_secret("API Key: "))
4344
def save_api_key(api_key):
4445
command = login_commands.SetApiKeyCommand()
4546
command.execute(api_key)

paperspace/cli/common.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import getpass
2+
13
import click
24
from click_didyoumean import DYMMixin
35
from click_help_colors import HelpColorsGroup
@@ -18,3 +20,13 @@ def del_if_value_is_none(dict_):
1820

1921
class ClickGroup(DYMMixin, HelpColorsGroup):
2022
pass
23+
24+
25+
def prompt_for_secret(prompt):
26+
def callback_fun(ctx, param, value):
27+
if value is None:
28+
value = getpass.getpass(prompt)
29+
30+
return value
31+
32+
return callback_fun

0 commit comments

Comments
 (0)