cometapi-cli 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cometapi_cli/__init__.py +1 -1
- cometapi_cli/commands/balance.py +26 -4
- {cometapi_cli-0.2.1.dist-info → cometapi_cli-0.2.2.dist-info}/METADATA +1 -1
- {cometapi_cli-0.2.1.dist-info → cometapi_cli-0.2.2.dist-info}/RECORD +7 -7
- {cometapi_cli-0.2.1.dist-info → cometapi_cli-0.2.2.dist-info}/WHEEL +0 -0
- {cometapi_cli-0.2.1.dist-info → cometapi_cli-0.2.2.dist-info}/entry_points.txt +0 -0
- {cometapi_cli-0.2.1.dist-info → cometapi_cli-0.2.2.dist-info}/licenses/LICENSE +0 -0
cometapi_cli/__init__.py
CHANGED
cometapi_cli/commands/balance.py
CHANGED
|
@@ -7,28 +7,50 @@ from typing import Annotated
|
|
|
7
7
|
import typer
|
|
8
8
|
|
|
9
9
|
from ..config import get_client
|
|
10
|
+
from ..console import err_console
|
|
10
11
|
from ..errors import handle_errors
|
|
11
12
|
from ..formatters import OutputFormat, output, resolve_format
|
|
12
13
|
|
|
14
|
+
BALANCE_SOURCE_ALIASES = {
|
|
15
|
+
"account": "account",
|
|
16
|
+
"key": "key",
|
|
17
|
+
"token": "key",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _normalize_balance_source(source: str | None) -> str | None:
|
|
22
|
+
if source is None:
|
|
23
|
+
return None
|
|
24
|
+
|
|
25
|
+
normalized = BALANCE_SOURCE_ALIASES.get(source.lower())
|
|
26
|
+
if normalized is not None:
|
|
27
|
+
return normalized
|
|
28
|
+
|
|
29
|
+
err_console.print(f"[red]Invalid source:[/] {source}. Valid sources: account, key")
|
|
30
|
+
raise typer.Exit(code=2)
|
|
31
|
+
|
|
13
32
|
|
|
14
33
|
@handle_errors
|
|
15
34
|
def balance(
|
|
16
35
|
ctx: typer.Context,
|
|
17
36
|
source: Annotated[
|
|
18
37
|
str | None,
|
|
19
|
-
typer.Option("--source", "-s", help="Data source: 'account' (full account) or '
|
|
38
|
+
typer.Option("--source", "-s", help="Data source: 'account' (full account) or 'key' (current API key)."),
|
|
39
|
+
] = None,
|
|
40
|
+
output_format: Annotated[
|
|
41
|
+
OutputFormat | None,
|
|
42
|
+
typer.Option("--format", "-f", help="Output format (table, json, yaml, csv, markdown)."),
|
|
20
43
|
] = None,
|
|
21
|
-
output_format: Annotated[OutputFormat | None, typer.Option("--format", "-f", help="Output format (table, json, yaml, csv, markdown).")] = None,
|
|
22
44
|
json_output: Annotated[bool, typer.Option("--json", help="Output as JSON.")] = False,
|
|
23
45
|
) -> None:
|
|
24
46
|
"""Show your CometAPI account balance.
|
|
25
47
|
|
|
26
48
|
By default shows account-level balance (requires access token), falling back
|
|
27
|
-
to per-
|
|
49
|
+
to per-key billing stats. Use --source to force a specific view.
|
|
28
50
|
"""
|
|
29
51
|
fmt = resolve_format(ctx, json_output, output_format)
|
|
30
52
|
client = get_client()
|
|
31
|
-
raw = client.get_balance(source=source)
|
|
53
|
+
raw = client.get_balance(source=_normalize_balance_source(source))
|
|
32
54
|
|
|
33
55
|
# For JSON output, pass raw data for maximum information
|
|
34
56
|
if fmt == OutputFormat.JSON:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cometapi-cli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: CometAPI CLI — official command-line interface for the CometAPI AI gateway
|
|
5
5
|
Project-URL: Homepage, https://github.com/cometapi-dev/cometapi-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/cometapi-dev/cometapi-cli
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
cometapi_cli/__init__.py,sha256=
|
|
1
|
+
cometapi_cli/__init__.py,sha256=YoHkL8RaBOgm8zi4mJO3F2ywNNSkk26kuGB8cjLLRrE,92
|
|
2
2
|
cometapi_cli/app.py,sha256=tFrkyfVVBYkjOA9zXP72bZ1csHI9HBnGF-Z4_4EkXkE,2784
|
|
3
3
|
cometapi_cli/client.py,sha256=4JkMSrjWwAQV8tmlwplZQ75gzt3zHno8ASKLgMCpYkU,9658
|
|
4
4
|
cometapi_cli/config.py,sha256=oJXQidKCOsKNYPnE8OfLLoOfsv0MSZEDICB6VShJRSA,3307
|
|
@@ -9,7 +9,7 @@ cometapi_cli/formatters.py,sha256=QrXpsQHRYiJ49Rwz_7dOMoKxCcnRPumZMrxH21ZQaMw,45
|
|
|
9
9
|
cometapi_cli/main.py,sha256=4NmO8MAAc_H30hahT6VNrdGdlaFlQ99AixKcRV5iDXE,168
|
|
10
10
|
cometapi_cli/commands/__init__.py,sha256=mihzLmD4ADkH9WnCBP2p1fn95lU3GyzTliAJ1XL5Ngg,29
|
|
11
11
|
cometapi_cli/commands/account.py,sha256=yGIY5iQeB4j1bISMUOqnvjcuD9HTd7VcWSvSFB6fAfo,1257
|
|
12
|
-
cometapi_cli/commands/balance.py,sha256=
|
|
12
|
+
cometapi_cli/commands/balance.py,sha256=BT96WTt2I7dCLBlAkZMX4KYliqC5C7QCXKNWCbXwldw,2353
|
|
13
13
|
cometapi_cli/commands/chat.py,sha256=5VuNOF7O3vjD0f8eD0faZ3xL2IFnSa2BNadxencoPJk,3937
|
|
14
14
|
cometapi_cli/commands/chat_repl.py,sha256=b9lkYnbbaOb0AlSpRcq3wWHmnhtTXvaqeJiUImsMEBY,8176
|
|
15
15
|
cometapi_cli/commands/config_cmd.py,sha256=JU4ZS8ur2Sq1MjMZKaGLaI1TdM3CAUDE45qsKDOxD_8,8528
|
|
@@ -20,8 +20,8 @@ cometapi_cli/commands/repl.py,sha256=b5z1jmEXOsCrb6fwEUyv-IKot929NIPQQAbA1uas1D4
|
|
|
20
20
|
cometapi_cli/commands/stats.py,sha256=6ULBb7rX5Q0yWuIxtYLataNPoJ_SkU3Y4RovgdVyROs,1388
|
|
21
21
|
cometapi_cli/commands/tasks.py,sha256=TW_Jgli7iyfIoHNyufbViAUMIieMNfsD8DMHt5mQA8Q,4625
|
|
22
22
|
cometapi_cli/commands/tokens.py,sha256=9KHer9MQOZvm_Ybxnhjb5_TtGgKyv3MtI5lqsHy-Qxg,3019
|
|
23
|
-
cometapi_cli-0.2.
|
|
24
|
-
cometapi_cli-0.2.
|
|
25
|
-
cometapi_cli-0.2.
|
|
26
|
-
cometapi_cli-0.2.
|
|
27
|
-
cometapi_cli-0.2.
|
|
23
|
+
cometapi_cli-0.2.2.dist-info/METADATA,sha256=Aveuc9r_GBg70ue7jZL4j1P6hkyFKTKruBQXa3kCk48,8624
|
|
24
|
+
cometapi_cli-0.2.2.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
25
|
+
cometapi_cli-0.2.2.dist-info/entry_points.txt,sha256=xoiE2ZVNNWXTq0JRBtzC8hJ2JkdKuaBNz_fEd8OJpLs,50
|
|
26
|
+
cometapi_cli-0.2.2.dist-info/licenses/LICENSE,sha256=-rBwHQzkmLbty07abmGvQvsRrvDeEQUkPDhNJfTcjdE,1065
|
|
27
|
+
cometapi_cli-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|