Rewrote using command factory

This commit is contained in:
Firq 2024-07-03 20:36:22 +02:00
parent 84571f1692
commit 537a0d8015
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20
12 changed files with 287 additions and 196 deletions

View file

@ -1,2 +1 @@
from .commands import commands
from .codes import StackStatus

View file

@ -1,73 +0,0 @@
from pydantic import BaseModel
class CommandListing(BaseModel):
command: str
description: str
cmd_host = CommandListing(
command="host",
description="Sets and gets the URI of the dockge instance. Remove any unnecessary subdomains/protocols from the URI"
)
cmd_login = CommandListing(
command="login",
description="Logs into a given dockge account, either with an interactive dialogue or by passing --user and --password",
)
cmd_logout = CommandListing(
command="logout",
description="Removes the credentials from the local storage.",
)
cmd_list = CommandListing(
command="list",
description="Lists all available stacks with their status",
)
cmd_status = CommandListing(
command="status",
description="Returns the status of one stack",
)
cmd_restart = CommandListing(
command="restart",
description="Restarts a given stack",
)
cmd_start = CommandListing(
command="start",
description="Starts a given stack",
)
cmd_stop = CommandListing(
command="stop",
description="Stops a given stack",
)
cmd_down = CommandListing(
command="down",
description="Stop & Downs a given stack",
)
cmd_update = CommandListing(
command="update",
description="Updates a stack",
)
cmd_exit = CommandListing(
command="exit",
description="Exits the CLI - this will reset all settings, including credentials and host",
)
cmd_debug = CommandListing(
command="debug",
description="debug",
)
cmd_help = CommandListing(
command="help",
description="Displays helping hints for commands",
)
commandlist = [cmd_host, cmd_login, cmd_logout, cmd_list, cmd_restart, cmd_update, cmd_exit, cmd_debug, cmd_help, cmd_status, cmd_start, cmd_stop, cmd_down]
commands = { k.command: k for k in commandlist }

View file

@ -0,0 +1,10 @@
import argparse
# pylint: disable=too-few-public-methods
class Arguments(argparse.Namespace):
command: str
# pylint: disable=too-few-public-methods
class Credentials(argparse.Namespace):
username: str
password: str