Documentation
¶
Overview ¶
Package utils provides common utilities for the gh-dxp extension.
Package utils provides common utilities for the gh-dxp extension.
Package utils provides command execution utilities for Linux systems.
revive:disable
Index ¶
- func AskForMultiline(question string) (string, error)
- func AskForString(question string, defaultAnswer string) (string, error)
- func AskToConfirm(question string) (bool, error)
- func CheckFilesUpdated(changedFiles []string, patterns []string) bool
- func ConvertTerminalOutputIntoList(changedFilesString string) []string
- func ConvertToGitRootRelativePath(exe Executor, currentPath, dir string) (string, error)
- func DirectoryExists(path string) (bool, error)
- func FileExists(path string) bool
- func GetChangedFiles(exe Executor) ([]string, error)
- func GetGitRootDirectory(exe Executor) (string, error)
- func GetTrackedChanges(exe Executor) ([]string, error)
- func GetUntrackedChanges(exe Executor) ([]string, error)
- func ListFilesInDirectory(exe Executor, directory string) ([]string, error)
- func RemoveFinalMsg(s *spinner.Spinner)
- func SetWorkDirToGitHubRoot(exe Executor) error
- func StartSpinner(msg string, finalMsg string) *spinner.Spinner
- type Executor
- type LinuxExecutorImpl
- type NotAGitHubRepoError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskForMultiline ¶ added in v0.9.4
AskForMultiline prompts the user for a multiline input and returns the response.
func AskForString ¶ added in v0.9.4
AskForString prompts the user for a string input and returns the response.
func AskToConfirm ¶ added in v0.9.4
AskToConfirm prompts the user with a yes/no question and returns their response.
func CheckFilesUpdated ¶ added in v0.9.5
CheckFilesUpdated checks if any of the specified patterns match the changed files.
func ConvertTerminalOutputIntoList ¶ added in v0.9.4
ConvertTerminalOutputIntoList converts terminal output on multiple lines to a list of strings
func ConvertToGitRootRelativePath ¶ added in v0.13.110
ConvertToGitRootRelativePath converts a given directory path to a path relative to the git root.
func DirectoryExists ¶ added in v0.13.6
DirectoryExists checks whether a directory exists.
func FileExists ¶ added in v0.0.2
FileExists returns true if a given file exists, and false if it doesn't.
func GetChangedFiles ¶ added in v0.9.4
GetChangedFiles returns a list of changed files in the current repo
func GetGitRootDirectory ¶ added in v0.2.4
GetGitRootDirectory returns the root directory of the current git repo.
func GetTrackedChanges ¶ added in v0.7.8
GetTrackedChanges returns a list of file names for changed files in the current repo
func GetUntrackedChanges ¶ added in v0.7.8
GetUntrackedChanges returns a list of file names for unchanged files in the current repo
func ListFilesInDirectory ¶ added in v0.2.4
ListFilesInDirectory returns a list of files in a given directory.
func RemoveFinalMsg ¶ added in v0.12.7
RemoveFinalMsg removes the finalmsg from a spinner. This is intended to be used if an error occurs to prevent conflicting terminal output
func SetWorkDirToGitHubRoot ¶ added in v0.6.2
SetWorkDirToGitHubRoot checks whether the current working directory is in a GitHub repo. If false, an error is raised. If true, the working directory is set to the root of that repo.
Types ¶
type Executor ¶
type Executor interface {
Command(name string, args ...string) (string, error)
CommandContext(ctx context.Context, name string, arg ...string) error
GH(args ...string) (string, error)
Chdir(dir string) error
}
Executor is an interface for running commands.
type LinuxExecutorImpl ¶
LinuxExecutorImpl is the type of the Executor interface for Linux systems.
func LinuxExecutor ¶
func LinuxExecutor() *LinuxExecutorImpl
LinuxExecutor returns a new LinuxExecutorImpl.
func (*LinuxExecutorImpl) Chdir ¶ added in v0.9.4
func (e *LinuxExecutorImpl) Chdir(dir string) error
Chdir changes the current working directory.
func (*LinuxExecutorImpl) Command ¶
func (e *LinuxExecutorImpl) Command(name string, args ...string) (string, error)
Command runs an OS command and returns its output.
func (*LinuxExecutorImpl) CommandContext ¶
CommandContext runs an OS command with a context and returns an error. The output is printed to stdout and stderr.
type NotAGitHubRepoError ¶ added in v0.4.2
type NotAGitHubRepoError struct {
Msg string
}
NotAGitHubRepoError signifies that the current working directory is not a GitHub repo.
func (*NotAGitHubRepoError) Error ¶ added in v0.4.2
func (e *NotAGitHubRepoError) Error() string
Signifies that the current working directory is not a GitHub repo.