mirror of
https://github.com/prdlk/gh-commit.git
synced 2026-09-16 23:16:25 +00:00
Replaces the Python/Crush/DuckDB implementation with a CGO-free Go binary: cobra CLI, modernc.org/sqlite storage, huh/lipgloss UI, and speed-tuned raw /api/generate calls (think:false, keep_alive, capped num_predict) against a local qwen3.5:2b. Ships as a gh extension via cli/gh-extension-precompile.
57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
|
"github.com/charmbracelet/lipgloss/table"
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/prdlk/gh-commit/internal/ui"
|
|
)
|
|
|
|
var listCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: "List all configured repositories",
|
|
Args: cobra.NoArgs,
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
ui.MagentaBoldf("Repositories")
|
|
ui.Println()
|
|
|
|
repos, err := store.ListRepos()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(repos) == 0 {
|
|
ui.Dimf("No repositories configured yet")
|
|
ui.Println()
|
|
ui.Infof("Run 'gh commit init' in a git repository to get started")
|
|
return nil
|
|
}
|
|
|
|
t := table.New().
|
|
Border(lipgloss.NormalBorder()).
|
|
Headers("Name", "Path", "Scopes").
|
|
StyleFunc(func(row, col int) lipgloss.Style {
|
|
s := lipgloss.NewStyle().Padding(0, 1)
|
|
if col == 2 {
|
|
s = s.Align(lipgloss.Right)
|
|
}
|
|
if row == table.HeaderRow || col == 0 {
|
|
s = s.Bold(true)
|
|
}
|
|
return s
|
|
})
|
|
for _, r := range repos {
|
|
t.Row(r.Name, r.Path, strconv.Itoa(r.ScopeCount))
|
|
}
|
|
fmt.Println(t)
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(listCmd)
|
|
}
|