Change module path from 'cburn' to 'github.com/theirongolddev/cburn' to enable standard Go remote installation: go install github.com/theirongolddev/cburn@latest This is a BREAKING CHANGE for any external code importing this module (though as a CLI tool, this is unlikely to affect anyone). All internal imports updated to use the new module path. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/theirongolddev/cburn/internal/cli"
|
|
"github.com/theirongolddev/cburn/internal/pipeline"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var modelsCmd = &cobra.Command{
|
|
Use: "models",
|
|
Short: "Model usage breakdown",
|
|
RunE: runModels,
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(modelsCmd)
|
|
}
|
|
|
|
func runModels(_ *cobra.Command, _ []string) error {
|
|
result, err := loadData()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(result.Sessions) == 0 {
|
|
fmt.Println("\n No sessions found.")
|
|
return nil
|
|
}
|
|
|
|
filtered, since, until := applyFilters(result.Sessions)
|
|
models := pipeline.AggregateModels(filtered, since, until)
|
|
|
|
if len(models) == 0 {
|
|
fmt.Println("\n No model data in the selected time range.")
|
|
return nil
|
|
}
|
|
|
|
fmt.Println()
|
|
fmt.Println(cli.RenderTitle(fmt.Sprintf("MODEL USAGE Last %dd", flagDays)))
|
|
fmt.Println()
|
|
|
|
rows := make([][]string, 0, len(models))
|
|
for _, ms := range models {
|
|
rows = append(rows, []string{
|
|
shortModel(ms.Model),
|
|
cli.FormatNumber(int64(ms.APICalls)),
|
|
cli.FormatTokens(ms.InputTokens),
|
|
cli.FormatTokens(ms.OutputTokens),
|
|
cli.FormatCost(ms.EstimatedCost),
|
|
fmt.Sprintf("%.1f%%", ms.SharePercent),
|
|
})
|
|
}
|
|
|
|
fmt.Print(cli.RenderTable(cli.Table{
|
|
Headers: []string{"Model", "Calls", "Input", "Output", "Cost", "Share"},
|
|
Rows: rows,
|
|
}))
|
|
|
|
return nil
|
|
}
|