Browse Source

Move Vultron commands into separate package

cmd/billing
Nick Chambers 5 months ago
parent
commit
e7159bb6a4
  1. 1
      setup.cfg
  2. 2
      vultron/cmds/__init__.py
  3. 12
      vultron/cmds/account.py
  4. 9
      vultron/cmds/help.py
  5. 10
      vultron/cmds/region.py
  6. 12
      vultron/cmds/vpc.py
  7. 39
      vultron/vultron.py

1
setup.cfg

@ -5,6 +5,7 @@ version = 0.1.0
[options]
packages =
vultron
vultron.cmds
install_requires =
click

2
vultron/cmds/__init__.py

@ -0,0 +1,2 @@
# FIXME: build this dynamically
__all__ = ["account", "help", "region", "vpc"]

12
vultron/cmds/account.py

@ -0,0 +1,12 @@
import vultron.cmd
class Account(vultron.cmd.Command):
"""Query for account information."""
def vultron_info(self, *args):
"""Display your account details."""
account = self.api.get("account")
display = vultron.display.render(self.out, [account["account"]])
print(display)

9
vultron/cmds/help.py

@ -0,0 +1,9 @@
import vultron.cmd
class Help(vultron.cmd.Command):
def init(self):
self.uses_api = False
def vultron_help(self, *args):
# FIXME: print global help message
pass

10
vultron/cmds/region.py

@ -0,0 +1,10 @@
import vultron.cmd
class Region(vultron.cmd.Command):
"""Query for information on Vultr regions."""
def vultron_list(self, *args):
regions = self.api.get("regions")
display = vultron.display.render(self.out, regions["regions"])
print(display)

12
vultron/cmds/vpc.py

@ -0,0 +1,12 @@
import vultron.cmd
class Vpc(vultron.cmd.Command):
"""Query for information on VPCs."""
def vultron_list(self, *args):
"""Display all VPCs."""
vpcs = self.api.get("vpcs")
display = vultron.display.render(self.out, vpcs["vpcs"])
print(display)

39
vultron/vultron.py

@ -4,44 +4,7 @@ import sys
import vultron.cmd
import vultron.display
class Help(vultron.cmd.Command):
def init(self):
self.uses_api = False
def vultron_help(self, *args):
# FIXME: print global help message
pass
class Account(vultron.cmd.Command):
"""Query for account information."""
def vultron_info(self, *args):
"""Display your account details."""
account = self.api.get("account")
display = vultron.display.render(self.out, [account["account"]])
print(display)
class VPC(vultron.cmd.Command):
"""Query for information on VPCs."""
def vultron_list(self, *args):
"""Display all VPCs."""
vpcs = self.api.get("vpcs")
display = vultron.display.render(self.out, vpcs["vpcs"])
print(display)
class Region(vultron.cmd.Command):
"""Query for information on Vultr regions."""
def vultron_list(self, *args):
regions = self.api.get("regions")
display = vultron.display.render(self.out, regions["regions"])
print(display)
from vultron.cmds import *
@click.command()
@click.option("--help", is_flag=True)

Loading…
Cancel
Save