Documentation ¶
Index ¶
- Constants
- Variables
- func CheckUpdateWithClient(currentVersion string, client HTTPClient) error
- func InstallUpdate(version, tag string) error
- func InstallUpdateWithAllDeps(version, tag string, client HTTPClient, fs FileSystem, downloader Downloader, ...) error
- func InstallUpdateWithDeps(version, tag string, client HTTPClient, fs FileSystem, downloader Downloader) error
- func InstallUpdateWithFS(version, tag string, client HTTPClient, fs FileSystem) error
- func NewCommitCmd() *cobra.Command
- func NewConfigCmd() *cobra.Command
- func NewProviderCmd() *cobra.Command
- func NewUpdateCmd(version string) *cobra.Command
- type CommitError
- type CommitOptions
- type CommitService
- type ConfigManager
- type DefaultFileSystem
- func (fs *DefaultFileSystem) MkdirAll(path string, perm os.FileMode) error
- func (fs *DefaultFileSystem) MkdirTemp(dir, pattern string) (string, error)
- func (fs *DefaultFileSystem) Remove(name string) error
- func (fs *DefaultFileSystem) RemoveAll(path string) error
- func (fs *DefaultFileSystem) Rename(oldpath, newpath string) error
- func (fs *DefaultFileSystem) Symlink(oldname, newname string) error
- func (fs *DefaultFileSystem) UserHomeDir() (string, error)
- type Downloader
- type Extractor
- type FileCopier
- type FileSystem
- type GithubRelease
- type HTTPClient
- type TerminalEditor
- type TextEditor
Constants ¶
const (
LANGUAGE_KEY = "output.lang"
)
Variables ¶
var ( // DefaultHTTPClient is the default HTTP client used for making requests DefaultHTTPClient HTTPClient = &http.Client{} // DefaultFS is the default file system implementation DefaultFS FileSystem = &DefaultFileSystem{} // DefaultDownloader is the default downloader implementation DefaultDownloader Downloader = &defaultDownloader{} // DefaultExtractor is the default extractor implementation DefaultExtractor Extractor = &defaultExtractor{} // DefaultFileCopier is the default file copier implementation DefaultFileCopier FileCopier = &defaultFileCopier{} )
Functions ¶
func CheckUpdateWithClient ¶ added in v0.2.3
func CheckUpdateWithClient(currentVersion string, client HTTPClient) error
CheckUpdateWithClient is like checkUpdate but uses the provided HTTP client Exported for testing
func InstallUpdate ¶ added in v0.2.3
InstallUpdate downloads and installs the specified version Parameters:
- version: The version to install (without 'v' prefix)
- tag: The complete tag name (with 'v' prefix)
Returns an error if the installation fails Exported for testing
func InstallUpdateWithAllDeps ¶ added in v0.2.3
func InstallUpdateWithAllDeps(version, tag string, client HTTPClient, fs FileSystem, downloader Downloader, extractor Extractor, copier FileCopier) error
InstallUpdateWithAllDeps is like InstallUpdate but uses all provided dependencies Exported for testing
func InstallUpdateWithDeps ¶ added in v0.2.3
func InstallUpdateWithDeps(version, tag string, client HTTPClient, fs FileSystem, downloader Downloader) error
InstallUpdateWithDeps is like InstallUpdate but uses the provided dependencies Exported for testing
func InstallUpdateWithFS ¶ added in v0.2.3
func InstallUpdateWithFS(version, tag string, client HTTPClient, fs FileSystem) error
InstallUpdateWithFS is like InstallUpdate but uses the provided file system Exported for testing
func NewCommitCmd ¶
NewCommitCmd creates and returns a new cobra.Command for the 'commit' subcommand. This command generates and creates a commit with staged changes in a Git or SVN repository.
The command supports the following flags:
- --config, -c: Config path for the repository (string)
- --rich, -r: Generate detailed commit message with more context (bool)
- --yes, -y: Skip confirmation prompt and commit automatically (bool)
- --dry-run: Preview the generated commit message without actually committing (bool)
- --svn: Use SVN instead of Git for version control operations (bool)
If no repository path is specified, it uses the current working directory. The command integrates with the root command's persistent configuration path.
Returns a configured cobra.Command ready to be added to the command hierarchy.
func NewConfigCmd ¶
NewConfigCmd creates and returns a new cobra command for managing configuration. This command serves as the parent command for all configuration-related subcommands. It initializes the configuration manager during pre-run and stores it in the command context.
The command includes the following subcommands: - get: Get configuration values - list: List configuration entries - reset: Reset configuration to default values - set: Set configuration values - path: Show configuration file path - remove: Remove configuration entries - append: Append values to configuration arrays - keys: List available configuration keys
The configuration manager is initialized using the config path provided via the global --config flag. If initialization fails, an error is returned and the command execution is stopped.
func NewProviderCmd ¶
func NewUpdateCmd ¶ added in v0.2.3
NewUpdateCmd creates a new cobra command for handling version updates It automatically downloads and installs the latest version if available
Types ¶
type CommitError ¶ added in v0.2.3
CommitError represents specific error types that can occur during commit operations
func (*CommitError) Error ¶ added in v0.2.3
func (e *CommitError) Error() string
type CommitOptions ¶
type CommitOptions struct { RepoPath string Rich bool DryRun bool UseSVN bool AutoYes bool ConfigPath string }
CommitOptions contains the configuration settings for the commit operation.
type CommitService ¶
type CommitService struct {
// contains filtered or unexported fields
}
CommitService handles the logic for committing changes to version control while integrating with the GPT service for generating commit messages. It manages the interaction between the version control system, API client, and configuration settings.
func NewCommitService ¶
func NewCommitService(options CommitOptions) (*CommitService, error)
NewCommitService creates a new CommitService instance with the provided options. It initializes the version control system (Git or SVN), configuration manager, and API client based on the given options.
Parameters:
- options: CommitOptions containing configuration path and VCS preferences
Returns:
- *CommitService: A new CommitService instance if successful
- error: An error if initialization fails due to VCS or config issues
func (*CommitService) Execute ¶
func (s *CommitService) Execute() error
Execute performs the commit operation with the following steps: 1. Checks for staged changes in the repository 2. Gets the filtered diff of staged changes 3. Generates a commit message using the diff 4. If dry-run is enabled, prints the generated message 5. Otherwise, handles the commit interaction
It returns an error if: - There are no staged changes - Failed to check staged changes - Failed to get diff - No changes found after filtering - Failed to generate commit message - Failed to handle commit interaction
type ConfigManager ¶
type ConfigManager interface { Get(key string) (interface{}, bool) List() (string, error) Reset(promptOnly bool) error Set(key string, value interface{}) error GetPath() string Remove(key string, value string) error Append(key string, value interface{}) error GetSupportedKeys() []string }
ConfigManager defines the interface for configuration management
type DefaultFileSystem ¶ added in v0.2.3
type DefaultFileSystem struct{}
DefaultFileSystem implements FileSystem using os package
func (*DefaultFileSystem) MkdirAll ¶ added in v0.2.3
func (fs *DefaultFileSystem) MkdirAll(path string, perm os.FileMode) error
func (*DefaultFileSystem) MkdirTemp ¶ added in v0.2.3
func (fs *DefaultFileSystem) MkdirTemp(dir, pattern string) (string, error)
func (*DefaultFileSystem) Remove ¶ added in v0.2.3
func (fs *DefaultFileSystem) Remove(name string) error
func (*DefaultFileSystem) RemoveAll ¶ added in v0.2.3
func (fs *DefaultFileSystem) RemoveAll(path string) error
func (*DefaultFileSystem) Rename ¶ added in v0.2.3
func (fs *DefaultFileSystem) Rename(oldpath, newpath string) error
func (*DefaultFileSystem) Symlink ¶ added in v0.2.3
func (fs *DefaultFileSystem) Symlink(oldname, newname string) error
func (*DefaultFileSystem) UserHomeDir ¶ added in v0.2.3
func (fs *DefaultFileSystem) UserHomeDir() (string, error)
type Downloader ¶ added in v0.2.3
Downloader interface for downloading files
type FileCopier ¶ added in v0.2.3
FileCopier interface for copying files
type FileSystem ¶ added in v0.2.3
type FileSystem interface { MkdirTemp(dir, pattern string) (string, error) RemoveAll(path string) error UserHomeDir() (string, error) MkdirAll(path string, perm os.FileMode) error Remove(name string) error Rename(oldpath, newpath string) error Symlink(oldname, newname string) error }
FileSystem interface for file operations
type GithubRelease ¶ added in v0.2.3
type GithubRelease struct {
TagName string `json:"tag_name"`
}
GithubRelease represents the GitHub release API response structure Exported for testing
type HTTPClient ¶ added in v0.2.3
HTTPClient interface for making HTTP requests
type TerminalEditor ¶ added in v0.2.3
type TerminalEditor struct{}
TerminalEditor implements TextEditor for terminal-based editing
type TextEditor ¶ added in v0.2.3
TextEditor represents an interface for text editing operations