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

Commit 25ea835

Browse files
committed
Refactor version command
1 parent 30eb036 commit 25ea835

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

paperspace/cli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,11 @@ def login(email, password, api_token_name):
11011101

11021102
@cli.command("logout", help="Log out / remove apiKey from config file")
11031103
def logout():
1104-
machines_api = client.API(config.CONFIG_HOST)
1105-
command = login_commands.LogOutCommand(api=machines_api)
1104+
command = login_commands.LogOutCommand()
1105+
command.execute()
1106+
1107+
1108+
@cli.command("version", help="Show the version and exit")
1109+
def version():
1110+
command = login_commands.ShowVersionCommand()
11061111
command.execute()

paperspace/commands/login.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from paperspace import login, logout
22
from paperspace.commands import CommandBase
3+
from paperspace.version import version
34

45

56
class LogInCommand(CommandBase):
@@ -12,3 +13,6 @@ def execute(self):
1213
logout()
1314

1415

16+
class ShowVersionCommand(CommandBase):
17+
def execute(self):
18+
self.logger.log(version)

paperspace/main.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def main():
11-
if len(sys.argv) >= 2 and sys.argv[1] in ('experiments', 'deployments', 'machines', 'login', 'logout'):
11+
if len(sys.argv) >= 2 and sys.argv[1] in ('experiments', 'deployments', 'machines', 'login', 'logout', 'version'):
1212
cli(sys.argv[1:])
1313

1414
args = sys.argv[:]
@@ -26,10 +26,6 @@ def main():
2626
usage(prog)
2727
sys.exit(0)
2828

29-
if cmd in ['version', '--version', '-v']:
30-
vers(prog)
31-
sys.exit(0)
32-
3329
if cmd == 'apikey' or cmd == 'apiKey':
3430
if not args or args[0] in help_opts:
3531
print('usage: %s' % apikey_usage(prog))

0 commit comments

Comments
 (0)