cli updates
Some checks failed
Nix Tests / nix-test (nix-runner) (push) Failing after 4m1s
Python Tests / python-test (push) Failing after 8m3s

This commit is contained in:
2025-10-08 22:12:37 -05:00
parent 5f46443d60
commit c16e970d3f
4 changed files with 68 additions and 10 deletions

View File

@@ -2,8 +2,9 @@ import argparse
import pathlib
import logging
import trygo_py_cliclient.config
import trygo_py_cliclient.client
import trygo_py_cliclient.cli.common
import trygo_py_cliclient.cli.register
import trygo_py_cliclient.cli.login
_logger = logging.getLogger(__name__)
@@ -17,11 +18,10 @@ def parse_args():
"--config-file", type=str, help="config file location", default="config.toml"
)
parser.add_argument(
"--display-name", type=str, help="config file location", default=""
)
parser.add_argument("--email", type=str, help="config file location", default="")
parser.add_argument("--password", type=str, help="config file location", default="")
subparsers = parser.add_subparsers(dest="cmd", required=True)
trygo_py_cliclient.cli.register.setup_parser(subparsers)
trygo_py_cliclient.cli.login.setup_parser(subparsers)
args = parser.parse_args()
return args
@@ -35,8 +35,7 @@ def main():
trygo_py_cliclient.cli.common.set_up_logging(
config,
)
_logger.info(f"Got args {args=}")
_logger.info(f"Loaded config {config=}")
clnt = trygo_py_cliclient.client.TryGoAPIClient("http://localhost:8080/")
response = clnt.register(args.email, args.password, args.display_name)
args.func(args)

View File

@@ -0,0 +1,28 @@
import argparse
import logging
import typing
import trygo_py_cliclient.client
_logger = logging.getLogger(__name__)
if typing.TYPE_CHECKING:
_SubparserType = argparse._SubParsersAction[argparse.ArgumentParser]
else:
_SubparserType = typing.Any
def setup_parser(subparsers: _SubparserType) -> None:
parser = subparsers.add_parser("login")
parser.add_argument("--email", type=str, help="config file location", default="")
parser.add_argument("--password", type=str, help="config file location", default="")
parser.set_defaults(func=run)
def run(args):
clnt = trygo_py_cliclient.client.TryGoAPIClient("http://localhost:8080/")
response = clnt.login(args.email, args.password)
_logger.info(response)

View File

@@ -0,0 +1,30 @@
import argparse
import logging
import typing
import trygo_py_cliclient.client
_logger = logging.getLogger(__name__)
if typing.TYPE_CHECKING:
_SubparserType = argparse._SubParsersAction[argparse.ArgumentParser]
else:
_SubparserType = typing.Any
def setup_parser(subparsers: _SubparserType) -> None:
parser = subparsers.add_parser("register")
parser.add_argument(
"--display-name", type=str, help="config file location", default=""
)
parser.add_argument("--email", type=str, help="config file location", default="")
parser.add_argument("--password", type=str, help="config file location", default="")
parser.set_defaults(func=run)
def run(args):
clnt = trygo_py_cliclient.client.TryGoAPIClient("http://localhost:8080/")
response = clnt.register(args.email, args.password, args.display_name)
_logger.info(response)

View File

@@ -158,7 +158,8 @@ class TryGoAPIClient:
_logger.info(f"Logging in user: {email}")
response_data = self._make_request("POST", "/auth/login", asdict(request_data))
response_data = self._make_request("POST", "/auth/tokens", asdict(request_data))
_logger.info(response_data)
# Parse response and create AuthResponse
auth_response = AuthResponse(