Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

Update CLI commands with improved error handling

Dane Schneider092ec536f3c7
diff --git a/app/cli/cmd/connect.go b/app/cli/cmd/connect.go
index 2a4fb373..18b43e34 100644
--- a/app/cli/cmd/connect.go
+++ b/app/cli/cmd/connect.go
@@ -50,7 +50,7 @@ func connect(cmd *cobra.Command, args []string) {
}
go func() {
- err := streamtui.StartStreamUI("", false)
+ err := streamtui.StartStreamUI("", false, true)
if err != nil {
term.OutputErrorAndExit("Error starting stream UI", err)
diff --git a/app/cli/cmd/update.go b/app/cli/cmd/update.go
index 1e22fbce..c9f4c8a0 100644
--- a/app/cli/cmd/update.go
+++ b/app/cli/cmd/update.go
@@ -59,6 +59,6 @@ func update(cmd *cobra.Command, args []string) {
lib.UpdateContextWithOutput(lib.UpdateContextParams{
Contexts: contexts,
OutdatedRes: *outdated,
- Req: outdated.Req,
+ ReqFn: outdated.ReqFn,
})
}
diff --git a/app/cli/cmd/usage.go b/app/cli/cmd/usage.go
index 9daaf983..bbf7fed0 100644
--- a/app/cli/cmd/usage.go
+++ b/app/cli/cmd/usage.go
@@ -64,26 +64,11 @@ func usage(cmd *cobra.Command, args []string) {
}
}
-func formatSpend(spend decimal.Decimal) string {
- if spend.IsZero() {
- return "$0.00"
- }
-
- spendStr := fmt.Sprintf("$%s", spend.StringFixed(4))
- for i := 0; i < 2; i++ {
- if strings.HasSuffix(spendStr, "0") {
- spendStr = spendStr[:len(spendStr)-1]
- }
- }
- if spendStr == "$0.00" {
- return "<$0.0001"
- }
- return spendStr
-}
-
func showUsage() {
auth.MustResolveAuthWithOrg()
+ term.StartSpinner("")
+
if !(creditsSession || creditsToday || creditsMonth || creditsCurrentPlan) {
if os.Getenv("PLANDEX_REPL_SESSION_ID") != "" {
creditsSession = true
@@ -159,13 +144,21 @@ func showUsage() {
table := tablewriter.NewWriter(&builder)
table.SetAutoWrapText(false)
- table.SetHeader([]string{"πŸ’° Current Balance", spendLbl, "πŸͺ™ Cache Savings"})
- table.Append([]string{balanceStr, spendStr, formatSpend(res.CacheSavings)})
+ table.SetHeader([]string{"πŸ’° Current Balance", spendLbl})
+ table.Append([]string{balanceStr, spendStr})
table.Render()
fmt.Fprintln(&builder)
- amountByStr := map[string]float64{}
+ if !res.CacheSavings.IsZero() {
+ table := tablewriter.NewWriter(&builder)
+ table.SetAutoWrapText(false)
+ table.SetHeader([]string{"🎯 Cache Savings"})
+ table.Append([]string{formatSpend(res.CacheSavings)})
+ table.Render()
+ fmt.Fprintln(&builder)
+ }
+ amountByStr := map[string]float64{}
if len(res.ByPlanId) > 0 {
if !creditsCurrentPlan {
table := tablewriter.NewWriter(&builder)
@@ -545,3 +538,20 @@ func showLog(cmd *cobra.Command, args []string) {
inputFn()
}
}
+
+func formatSpend(spend decimal.Decimal) string {
+ if spend.IsZero() {
+ return "$0.00"
+ }
+
+ spendStr := fmt.Sprintf("$%s", spend.StringFixed(4))
+ for i := 0; i < 2; i++ {
+ if strings.HasSuffix(spendStr, "0") {
+ spendStr = spendStr[:len(spendStr)-1]
+ }
+ }
+ if spendStr == "$0.00" {
+ return "<$0.0001"
+ }
+ return spendStr
+}