feat(cli): add read-only list and show subcommands
tapir list — table of stored summaries (date, title|id, channel, AI, fallback), recent-first. tapir show <video-id> — full summary with highlights and takeaways. DSN + user id from TAPIR_DB_DSN/TAPIR_USER_ID, never hardcoded. main.go gains a minimal os.Args[1] dispatcher kept flat so Worker F's auth/run cases union cleanly at merge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"gitea.d-ma.be/mathias/tapir/internal/adapters/store"
|
||||
)
|
||||
|
||||
// Env var names for the read-only CLI. DSN and user id are never hardcoded — the
|
||||
// store holds confidential summaries, so the caller supplies both.
|
||||
const (
|
||||
envDSN = "TAPIR_DB_DSN"
|
||||
envUserID = "TAPIR_USER_ID"
|
||||
)
|
||||
|
||||
// openStoreFromEnv reads TAPIR_DB_DSN and TAPIR_USER_ID and opens a store. The
|
||||
// returned close func releases the pool; callers defer it. Both vars are
|
||||
// required: an empty value is a usage error, not a silent default.
|
||||
func openStoreFromEnv(ctx context.Context) (s *store.Store, userID string, closeFn func(), err error) {
|
||||
dsn := os.Getenv(envDSN)
|
||||
if dsn == "" {
|
||||
return nil, "", nil, fmt.Errorf("%s is required", envDSN)
|
||||
}
|
||||
userID = os.Getenv(envUserID)
|
||||
if userID == "" {
|
||||
return nil, "", nil, fmt.Errorf("%s is required", envUserID)
|
||||
}
|
||||
s, err = store.New(ctx, dsn)
|
||||
if err != nil {
|
||||
return nil, "", nil, err
|
||||
}
|
||||
return s, userID, s.Close, nil
|
||||
}
|
||||
Reference in New Issue
Block a user