Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func outputStatus(cmd *cobra.Command, status common.Status) {
}
}

cmd.Println("Space Usage")
cmd.Printf("Space: %s\n", status.SpaceID)
cmd.Printf("Compute: %g/%g hours (%s)\n", computeHours, computeLimitHours, formatPercent(computePercent))
cmd.Printf("Storage: %s/1TiB (%s)\n", storageStr, formatPercent(storagePercent))
if len(parts) > 0 {
Expand Down
12 changes: 7 additions & 5 deletions internal/cmd/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestStatusCmd(t *testing.T) {
name: "text output",
args: []string{"status"},
setup: successSetup,
wantStdout: `Space Usage
wantStdout: `Space: test-project
Compute: 2/10 hours (20%)
Storage: 512MiB/1TiB (0%)
Databases: 2 (1 running, 1 paused)
Expand All @@ -138,7 +138,8 @@ Databases: 2 (1 running, 1 paused)
"databases": {
"running": 1,
"paused": 1
}
},
"space_id": "test-project"
}
`,
},
Expand All @@ -151,6 +152,7 @@ compute_minutes: 120
databases:
paused: 1
running: 1
space_id: test-project
storage_limit_mib: 1.048576e+06
storage_mib: 512
`,
Expand All @@ -159,7 +161,7 @@ storage_mib: 512
name: "usage alias",
args: []string{"usage"},
setup: successSetup,
wantStdout: `Space Usage
wantStdout: `Space: test-project
Compute: 2/10 hours (20%)
Storage: 512MiB/1TiB (0%)
Databases: 2 (1 running, 1 paused)
Expand Down Expand Up @@ -188,7 +190,7 @@ Databases: 2 (1 running, 1 paused)
JSON200: &databases,
}, nil)
},
wantStdout: `Space Usage
wantStdout: `Space: test-project
Compute: 2/10 hours (20%)
Storage: 512MiB/1TiB (0%)
Databases: 1 (1 running)
Expand Down Expand Up @@ -218,7 +220,7 @@ Cost: $12.34 so far this cycle ($27.50 estimated total)
JSON200: &databases,
}, nil)
},
wantStdout: `Space Usage
wantStdout: `Space: test-project
Compute: 2/10 hours (20%)
Storage: 512MiB/1TiB (0%)
Databases: 1 (1 running)
Expand Down
2 changes: 2 additions & 0 deletions internal/common/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Status struct {
EstimatedTotalCost *float64 `json:"estimated_total_cost,omitempty"`
BillingPeriodStart *time.Time `json:"billing_period_start,omitempty"`
BillingPeriodEnd *time.Time `json:"billing_period_end,omitempty"`
SpaceID string `json:"space_id"`
}

// FetchStatus fetches space usage and database counts from the API.
Expand Down Expand Up @@ -120,5 +121,6 @@ func FetchStatus(ctx context.Context, client api.ClientWithResponsesInterface, p
EstimatedTotalCost: spaceStatus.EstimatedTotalCost,
BillingPeriodStart: spaceStatus.BillingPeriodStart,
BillingPeriodEnd: spaceStatus.BillingPeriodEnd,
SpaceID: projectID,
}, nil
}