deepctl-cmd-billing 0.0.2__tar.gz → 0.1.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepctl-cmd-billing
3
- Version: 0.0.2
3
+ Version: 0.1.0
4
4
  Summary: Billing command for deepctl
5
5
  Author-email: Deepgram <devrel@deepgram.com>
6
6
  Maintainer-email: Deepgram <devrel@deepgram.com>
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
- Requires-Dist: deepctl-core>=0.1.10
17
+ Requires-Dist: deepctl-core>=0.2.16
18
18
  Requires-Dist: click>=8.0.0
19
19
  Requires-Dist: rich>=13.0.0
20
20
  Requires-Dist: pydantic>=2.0.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "deepctl-cmd-billing"
7
- version = "0.0.2" # x-release-please-version
7
+ version = "0.1.0" # x-release-please-version
8
8
  description = "Billing command for deepctl"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -21,7 +21,7 @@ classifiers = [
21
21
  keywords = ["deepgram", "cli", "billing", "usage"]
22
22
  requires-python = ">=3.10"
23
23
  dependencies = [
24
- "deepctl-core>=0.1.10",
24
+ "deepctl-core>=0.2.16",
25
25
  "click>=8.0.0",
26
26
  "rich>=13.0.0",
27
27
  "pydantic>=2.0.0",
@@ -10,6 +10,8 @@ from deepctl_core import (
10
10
  BaseResult,
11
11
  Config,
12
12
  DeepgramClient,
13
+ get_output_format,
14
+ get_status_console,
13
15
  )
14
16
  from rich.console import Console
15
17
  from rich.table import Table
@@ -17,6 +19,9 @@ from rich.table import Table
17
19
  from .models import BalanceInfo, BillingResult
18
20
 
19
21
  console = Console()
22
+ # Status/progress chrome must never touch stdout, or it corrupts JSON/CSV
23
+ # output that callers pipe into jq and friends.
24
+ status_console = get_status_console()
20
25
 
21
26
 
22
27
  class BillingCommand(BaseCommand):
@@ -116,7 +121,7 @@ class BillingCommand(BaseCommand):
116
121
  return result
117
122
 
118
123
  except Exception as e:
119
- console.print(f"[red]Error:[/red] {e}")
124
+ status_console.print(f"[red]Error:[/red] {e}")
120
125
  return BaseResult(status="error", message=str(e))
121
126
 
122
127
  def _show_balances(
@@ -125,21 +130,16 @@ class BillingCommand(BaseCommand):
125
130
  project_id: str | None,
126
131
  result: BillingResult,
127
132
  ) -> None:
128
- console.print("[blue]Fetching balances...[/blue]")
133
+ status_console.print("[blue]Fetching balances...[/blue]")
129
134
  data = client.get_balances(project_id=project_id)
130
135
 
131
136
  balances_raw = data.get("balances", [])
132
137
  if not balances_raw:
133
- console.print("[yellow]No balances found[/yellow]")
138
+ status_console.print("[yellow]No balances found[/yellow]")
134
139
  return
135
140
 
136
- table = Table(
137
- title="Account Balances", show_header=True, header_style="bold blue"
138
- )
139
- table.add_column("Balance ID", style="dim")
140
- table.add_column("Amount", justify="right", style="green")
141
- table.add_column("Units")
142
-
141
+ # Always populate the returned result; only the human table render
142
+ # is gated on default mode (json/yaml/csv are emitted by the framework).
143
143
  for b in balances_raw:
144
144
  b_data = (
145
145
  b
@@ -152,9 +152,19 @@ class BillingCommand(BaseCommand):
152
152
  units=b_data.get("units", ""),
153
153
  )
154
154
  result.balances.append(info)
155
- table.add_row(info.balance_id, f"{info.amount:,.2f}", info.units)
156
155
 
157
- console.print(table)
156
+ if get_output_format() == "default":
157
+ table = Table(
158
+ title="Account Balances", show_header=True, header_style="bold blue"
159
+ )
160
+ table.add_column("Balance ID", style="dim")
161
+ table.add_column("Amount", justify="right", style="green")
162
+ table.add_column("Units")
163
+
164
+ for info in result.balances:
165
+ table.add_row(info.balance_id, f"{info.amount:,.2f}", info.units)
166
+
167
+ console.print(table)
158
168
 
159
169
  def _show_breakdown(
160
170
  self,
@@ -166,7 +176,7 @@ class BillingCommand(BaseCommand):
166
176
  grouping: str | None = None,
167
177
  ) -> None:
168
178
 
169
- console.print("[blue]Fetching billing breakdown...[/blue]")
179
+ status_console.print("[blue]Fetching billing breakdown...[/blue]")
170
180
  data = client.get_billing_breakdown(
171
181
  project_id=project_id,
172
182
  start=start,
@@ -176,6 +186,11 @@ class BillingCommand(BaseCommand):
176
186
 
177
187
  result.breakdown = data
178
188
 
189
+ # Human display only in default mode; json/yaml/csv are emitted by the
190
+ # framework from result.breakdown.
191
+ if get_output_format() != "default":
192
+ return
193
+
179
194
  # Display breakdown summary
180
195
  resolution = data.get("resolution", {})
181
196
  if resolution:
@@ -205,6 +220,6 @@ class BillingCommand(BaseCommand):
205
220
 
206
221
  console.print(table)
207
222
  else:
208
- console.print(
223
+ status_console.print(
209
224
  "[dim]No breakdown data available for the specified period[/dim]"
210
225
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepctl-cmd-billing
3
- Version: 0.0.2
3
+ Version: 0.1.0
4
4
  Summary: Billing command for deepctl
5
5
  Author-email: Deepgram <devrel@deepgram.com>
6
6
  Maintainer-email: Deepgram <devrel@deepgram.com>
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
- Requires-Dist: deepctl-core>=0.1.10
17
+ Requires-Dist: deepctl-core>=0.2.16
18
18
  Requires-Dist: click>=8.0.0
19
19
  Requires-Dist: rich>=13.0.0
20
20
  Requires-Dist: pydantic>=2.0.0
@@ -1,4 +1,4 @@
1
- deepctl-core>=0.1.10
1
+ deepctl-core>=0.2.16
2
2
  click>=8.0.0
3
3
  rich>=13.0.0
4
4
  pydantic>=2.0.0