Files
mcq/cmd/mcq/list.go
Kyle Isom 3d5f52729f Add CLI client subcommands and MCP server
Adds push, list, get, delete, and login subcommands backed by an HTTP
API client, plus an MCP server for tool-based access to the document
queue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 00:08:55 -07:00

45 lines
862 B
Go

package main
import (
"context"
"fmt"
"os"
"text/tabwriter"
"github.com/spf13/cobra"
)
func listCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "List documents in the queue",
Args: cobra.NoArgs,
RunE: func(_ *cobra.Command, _ []string) error {
c, err := newClient()
if err != nil {
return err
}
docs, err := c.ListDocuments(context.Background())
if err != nil {
return fmt.Errorf("list documents: %w", err)
}
w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
_, _ = fmt.Fprintln(w, "SLUG\tTITLE\tPUSHED BY\tPUSHED AT\tREAD")
for _, d := range docs {
read := "no"
if d.Read {
read = "yes"
}
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", d.Slug, d.Title, d.PushedBy, d.PushedAt, read)
}
_ = w.Flush()
return nil
},
}
addClientFlags(cmd)
return cmd
}