Documentation
¶
Overview ¶
Package reposynccli provides CLI commands for forge API-based repository sync (GitHub, GitLab, Gitea). It bridges CLI commands → forge providers → reposync executor.
Index ¶
- func CreateForgeProviderRaw(providerName, token, baseURL string, sshPort int) (reposync.ForgeProvider, error)
- func CreateProviderFromSource(src *config.ForgeSource, ws *config.Workspace, cfg *config.Config) (reposync.ForgeProvider, error)
- func NewForgeProviderWithAuth(providerName, token, baseURL string, sshPort int) (provider.ProviderWithAuth, error)
- func ParseDuration(s string) (time.Duration, error)
- func ParseLanguages(s string) []string
- func PrintWarningsForProvider(providerName string, filter *MetadataFilter, w io.Writer)
- func RunConfigGenerate(cmd *cobra.Command, opts *ConfigGenerateOptions) error
- func RunStatus(cmd *cobra.Command, opts *StatusOptions, loader SpecLoader) error
- type CommandFactory
- type ConfigData
- type ConfigGenerateOptions
- type ConsoleProgressSink
- type DiagnosticProgressAdapter
- type FileSpecLoader
- type FromForgeOptions
- type MetadataFilter
- type SpecLoader
- type StatusOptions
- type StatusProgressIndicator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateForgeProviderRaw ¶
func CreateForgeProviderRaw(providerName, token, baseURL string, sshPort int) (reposync.ForgeProvider, error)
CreateForgeProviderRaw creates a provider from raw strings and narrows it to reposync.ForgeProvider. It is the entry point for sync callers (and other packages like workspacecli); doctor uses NewForgeProviderWithAuth directly when it needs the auth-capable interface.
func CreateProviderFromSource ¶
func CreateProviderFromSource(src *config.ForgeSource, ws *config.Workspace, cfg *config.Config) (reposync.ForgeProvider, error)
CreateProviderFromSource creates a forge provider from config types with profile fallback. This handles the common pattern of extracting provider settings from ForgeSource, falling back to Workspace settings, then to profile settings from the config chain.
func NewForgeProviderWithAuth ¶
func NewForgeProviderWithAuth(providerName, token, baseURL string, sshPort int) (provider.ProviderWithAuth, error)
NewForgeProviderWithAuth is the single owner of forge-provider construction. It maps a provider name to the concrete github/gitlab/gitea provider and returns it as provider.ProviderWithAuth — the richest common interface, so callers that need token validation or rate-limit access (e.g. doctor) get them, while sync callers narrow it to reposync.ForgeProvider via CreateForgeProviderRaw. Keeping this switch in exactly one place is the point: per-provider wiring — notably the GitLab SSH port — can no longer drift between the from_forge, wizard, config-loader and doctor paths.
func ParseDuration ¶
ParseDuration parses duration strings with extended unit support. Supports: s, m (minute), h, d (day), w (week), M (month), y (year) Examples: "30d", "6M", "1y", "2w".
func ParseLanguages ¶
ParseLanguages parses a comma-separated list of languages. Returns lowercase language names. Examples: "go,rust" -> ["go", "rust"], "Go, Rust" -> ["go", "rust"].
func PrintWarningsForProvider ¶
func PrintWarningsForProvider(providerName string, filter *MetadataFilter, w io.Writer)
PrintWarningsForProvider prints warnings about filter limitations for specific providers.
func RunConfigGenerate ¶
func RunConfigGenerate(cmd *cobra.Command, opts *ConfigGenerateOptions) error
RunConfigGenerate executes the config generation logic.
func RunStatus ¶
func RunStatus(cmd *cobra.Command, opts *StatusOptions, loader SpecLoader) error
RunStatus executes the status checks.
Types ¶
type CommandFactory ¶
type CommandFactory struct {
Use string
Short string
Orchestrator reposync.Runner
SpecLoader SpecLoader
Version string
Commit string
BuildDate string
}
CommandFactory builds a Cobra command tree that can be embedded into other CLIs.
func (CommandFactory) NewRootCmd ¶
func (f CommandFactory) NewRootCmd() *cobra.Command
NewRootCmd returns a root command suitable for standalone binary usage.
type ConfigData ¶
type ConfigData struct {
Plan reposync.PlanRequest
Run reposync.RunOptions
}
ConfigData contains plan + run inputs loaded from a config file.
type ConfigGenerateOptions ¶
type ConfigGenerateOptions struct {
Provider string
Organization string
Path string
Token string
BaseURL string
CloneProto string
SSHPort int
Strategy string
Parallel int
MaxRetries int
Output string
IncludeArchived bool
IncludeForks bool
IncludePrivate bool
IsUser bool
IncludeSubgroups bool
SubgroupMode string
FullOutput bool
// Metadata filters
FilterLanguage string // Comma-separated languages (e.g., "go,rust")
FilterMinStars int // Minimum star count
FilterMaxStars int // Maximum star count (0 = unlimited)
FilterLastPush string // Activity filter (e.g., "30d", "6M", "1y")
FilterInclude []string
FilterExclude []string
}
ConfigGenerateOptions holds options for config generate command.
type ConsoleProgressSink ¶
ConsoleProgressSink prints a simple textual progress log.
func (ConsoleProgressSink) OnComplete ¶
func (s ConsoleProgressSink) OnComplete(result reposync.ActionResult)
OnComplete implements ProgressSink.
func (ConsoleProgressSink) OnProgress ¶
func (s ConsoleProgressSink) OnProgress(action reposync.Action, message string, progress float64)
OnProgress implements ProgressSink.
func (ConsoleProgressSink) OnStart ¶
func (s ConsoleProgressSink) OnStart(action reposync.Action)
OnStart implements ProgressSink.
type DiagnosticProgressAdapter ¶
type DiagnosticProgressAdapter struct {
// contains filtered or unexported fields
}
DiagnosticProgressAdapter adapts StatusProgressIndicator to the diagnostic executor's needs.
func (*DiagnosticProgressAdapter) OnRepoComplete ¶
func (a *DiagnosticProgressAdapter) OnRepoComplete(health reposync.RepoHealth)
OnRepoComplete notifies when a repository check completes.
func (*DiagnosticProgressAdapter) OnRepoStart ¶
func (a *DiagnosticProgressAdapter) OnRepoStart(repo reposync.RepoSpec)
OnRepoStart notifies when a repository check starts.
type FileSpecLoader ¶
type FileSpecLoader struct {
// Optional defaults if the file omits values.
DefaultStrategy reposync.Strategy
DefaultParallel int
DefaultRetries int
}
FileSpecLoader loads configuration from a YAML file on disk.
func (FileSpecLoader) Load ¶
func (l FileSpecLoader) Load(ctx context.Context, path string) (ConfigData, error)
Load implements SpecLoader.
type FromForgeOptions ¶
type FromForgeOptions struct {
Provider string
Organization string
TargetPath string
Token string
BaseURL string // API endpoint (http/https only)
CloneProto string // Clone protocol: ssh, https (default: ssh)
SSHPort int // Custom SSH port (0 = default 22)
SSHKeyPath string // SSH private key file path
SSHKeyContent string // SSH private key content (use env var)
Strategy string
Parallel int
MaxRetries int
Resume bool
DryRun bool
StateFile string
IncludeArchived bool
IncludeForks bool
IncludePrivate bool
CleanupOrphans bool
IsUser bool
IncludeSubgroups bool // GitLab: include subgroups
SubgroupMode string // GitLab: flat | nested
// Metadata filters
FilterLanguage string // Comma-separated languages (e.g., "go,rust")
FilterMinStars int // Minimum star count
FilterMaxStars int // Maximum star count (0 = unlimited)
FilterLastPush string // Activity filter (e.g., "30d", "6M", "1y")
FilterInclude []string
FilterExclude []string
}
FromForgeOptions holds options for from-forge sync command.
type MetadataFilter ¶
type MetadataFilter struct {
Languages []string // Lowercase language names to include (e.g., ["go", "rust"])
MinStars int // Minimum star count (0 = no minimum)
MaxStars int // Maximum star count (0 = unlimited)
LastPushAfter time.Time // Only include repos pushed after this time
}
MetadataFilter filters repositories by metadata fields.
func BuildFilterFromOptions ¶
func BuildFilterFromOptions(language string, minStars, maxStars int, lastPushWithin string) (*MetadataFilter, error)
BuildFilterFromOptions creates a MetadataFilter from CLI option values.
func (*MetadataFilter) IsEmpty ¶
func (f *MetadataFilter) IsEmpty() bool
IsEmpty returns true if no filters are configured.
func (*MetadataFilter) Match ¶
func (f *MetadataFilter) Match(repo *provider.Repository) bool
Match returns true if the repository passes all filter criteria.
type SpecLoader ¶
type SpecLoader interface {
Load(ctx context.Context, path string) (ConfigData, error)
}
SpecLoader loads repository specs from a source (e.g., YAML file).
type StatusOptions ¶
type StatusOptions struct {
ConfigFile string
Path string
ScanDepth int
SkipFetch bool
Timeout time.Duration
Parallel int
Verbose bool
Format string // default, json, compact, tui
UseTUI bool // Use interactive TUI mode
SaveHistory bool // Save snapshot to history
HistoryDir string // History directory (default: ~/.gz-git/history)
}
StatusOptions holds options for the status command.
type StatusProgressIndicator ¶
type StatusProgressIndicator struct {
// contains filtered or unexported fields
}
StatusProgressIndicator provides real-time progress updates for health checks.
func NewStatusProgressIndicator ¶
func NewStatusProgressIndicator(out io.Writer, _ int, quiet bool) *StatusProgressIndicator
NewStatusProgressIndicator creates a progress indicator.
func (*StatusProgressIndicator) Done ¶
func (p *StatusProgressIndicator) Done()
Done signals that all health checks are complete.
func (*StatusProgressIndicator) OnComplete ¶
func (p *StatusProgressIndicator) OnComplete(health reposync.RepoHealth)
OnComplete is called when a repository health check completes.
func (*StatusProgressIndicator) OnStart ¶
func (p *StatusProgressIndicator) OnStart(_ reposync.RepoSpec)
OnStart is called when a repository health check starts.