go-scm/cmd/collect/cmd_papers.go
Virgil 305aa0da6f
Some checks failed
Security Scan / security (push) Failing after 8s
Test / test (push) Successful in 4m12s
chore(ax): normalize SPDX header identifier
2026-03-30 00:54:20 +00:00

65 lines
1.5 KiB
Go

// SPDX-License-Identifier: EUPL-1.2
package collect
import (
"context"
"dappco.re/go/core/i18n"
"dappco.re/go/core/scm/collect"
"forge.lthn.ai/core/cli/pkg/cli"
)
// Papers command flags
var (
papersSource string
papersCategory string
papersQuery string
)
// addPapersCommand adds the 'papers' subcommand to the collect parent.
func addPapersCommand(parent *cli.Command) {
papersCmd := &cli.Command{
Use: "papers",
Short: i18n.T("cmd.collect.papers.short"),
Long: i18n.T("cmd.collect.papers.long"),
RunE: func(cmd *cli.Command, args []string) error {
return runPapers()
},
}
cli.StringFlag(papersCmd, &papersSource, "source", "s", "all", i18n.T("cmd.collect.papers.flag.source"))
cli.StringFlag(papersCmd, &papersCategory, "category", "c", "", i18n.T("cmd.collect.papers.flag.category"))
cli.StringFlag(papersCmd, &papersQuery, "query", "q", "", i18n.T("cmd.collect.papers.flag.query"))
parent.AddCommand(papersCmd)
}
func runPapers() error {
if papersQuery == "" {
return cli.Err("--query (-q) is required")
}
cfg := newConfig()
setupVerboseLogging(cfg)
collector := &collect.PapersCollector{
Source: papersSource,
Category: papersCategory,
Query: papersQuery,
}
if cfg.DryRun {
cli.Info("Dry run: would collect papers from " + papersSource)
return nil
}
ctx := context.Background()
result, err := collector.Collect(ctx, cfg)
if err != nil {
return cli.Wrap(err, "papers collection failed")
}
printResult(result)
return nil
}