Added '--raw' option to vds remove

This commit is contained in:
lulzette 2022-07-22 03:01:21 +03:00
parent 288ccd7357
commit b2872e92d9

View File

@ -576,7 +576,7 @@ def vds_stop(vds_id: Optional[int] = typer.Argument(None), raw: bool = typer.Opt
@servers_app.command("clone") @servers_app.command("clone")
def vds_clone(vds_id: Optional[int] = typer.Argument(None), def vds_clone(vds_id: Optional[int] = typer.Argument(None),
raw: bool = typer.Option(False, help="Say hi formally.")): raw: bool = typer.Option(False, help="Get result as raw json")):
""" """
Clone VDS Clone VDS
""" """
@ -587,7 +587,7 @@ def vds_clone(vds_id: Optional[int] = typer.Argument(None),
error="No VDS ID provided" error="No VDS ID provided"
) )
) )
return 1 sys.exit(1)
vds_list() vds_list()
vds_id = input("Enter VDS ID: ") vds_id = input("Enter VDS ID: ")
new_vds = Server.clone(vds_id) new_vds = Server.clone(vds_id)
@ -611,17 +611,29 @@ def vds_clone(vds_id: Optional[int] = typer.Argument(None),
@servers_app.command("remove") @servers_app.command("remove")
def vds_remove(vds_id: Optional[int] = typer.Argument(None)): def vds_remove(vds_id: Optional[int] = typer.Argument(None),
raw: bool = typer.Option(False, help="Get result as raw json")):
""" """
Remove VDS Remove VDS
""" """
if vds_id is None: if vds_id is None:
if raw:
print(
dict(
error="No VDS ID provided"
)
)
sys.exit(1)
vds_list() vds_list()
vds_id = input("Enter VDS ID: ") vds_id = input("Enter VDS ID: ")
result = Server.remove(vds_id) result = Server.remove(vds_id)
if result is None: if result is None:
print(typer.style("Error", fg=typer.colors.RED)) print(typer.style("Error", fg=typer.colors.RED))
sys.exit(1) sys.exit(1)
else:
if raw:
print(result)
sys.exit(0)
for frame in cycle(r'-\|/'): for frame in cycle(r'-\|/'):
state = Server.get_vds(vds_id) state = Server.get_vds(vds_id)
if not state.get('server'): if not state.get('server'):