Update commands to indicate which need the API key
This commit is contained in:
parent
0a1885644b
commit
9a27ccb8d7
|
@ -35,12 +35,12 @@ class Command:
|
|||
def __init__(self, prog, api_key, out):
|
||||
self.prog = prog
|
||||
self.out = out
|
||||
self.uses_api = True
|
||||
self.needs_api_key = True
|
||||
self.default = "help"
|
||||
|
||||
self.init()
|
||||
|
||||
if self.uses_api and api_key is None:
|
||||
if self.needs_api_key and api_key is None:
|
||||
raise NoApiKey()
|
||||
|
||||
self.api = vultron.api.Client(api_key)
|
||||
|
@ -55,6 +55,8 @@ class Command:
|
|||
|
||||
data = fn(*args)
|
||||
|
||||
# FIXME: Let functions choose the output format. This will allow help
|
||||
# functions to still return a rendering.
|
||||
if data is not None:
|
||||
display = vultron.display.FORMATS[self.out](data)
|
||||
print(display.render())
|
||||
|
|
|
@ -3,7 +3,7 @@ import vultron.display
|
|||
|
||||
class Help(vultron.cmd.Command):
|
||||
def init(self):
|
||||
self.uses_api = False
|
||||
self.needs_api_key = False
|
||||
|
||||
def vultron_help(self):
|
||||
print("stub help message here")
|
||||
|
|
|
@ -4,6 +4,9 @@ import vultron.display
|
|||
class Region(vultron.cmd.Command):
|
||||
"""Query for information on Vultr regions."""
|
||||
|
||||
def init(self):
|
||||
self.needs_api_key = False
|
||||
|
||||
def vultron_list(self):
|
||||
"""Display all available regions."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue