Documentation
¶
Overview ¶
Package configfile provides a simple interface for reading and writing configuration file. The configuration file is stored in the user's GitHub CLI configuration under a dedicated section. The configuration file is encoded in YAML format.
Index ¶
- Constants
- func ConfigurationExists() bool
- func GetHosts() []string
- func GetListOfSupportedFormats(quote bool) (formats []string)
- func GetRepositorySlugFromURL(repo Repository) string
- func GetTokens() map[string]string
- func Import(format, input string)
- func OpenLins(links []string)
- type Configuration
- func (conf *Configuration) AppendRepositories(user *resources.User, repos ...resources.Repository)
- func (conf Configuration) AuthenticateURL(targetURL *string)
- func (conf Configuration) Cleanup()
- func (conf *Configuration) Copy() *Configuration
- func (conf Configuration) Display(format, output string, export bool, filters []string)
- func (conf *Configuration) Edit(format, editor string)
- func (conf *Configuration) FilterRepositories(repositories *[]resources.Repository)
- func (conf Configuration) GeneralizeURL(targetURL *string)
- func (conf *Configuration) GetProgressbarDescriptionForVerb(verb string, repo Repository) string
- func (conf Configuration) ListUntracked() (untracked []string)
- func (conf *Configuration) Overwrite(from *Configuration)
- func (conf Configuration) Remove(purge bool)
- func (conf *Configuration) SanitizeDirectory()
- func (conf Configuration) Save()
- type Profile
- type Profiles
- type PullRequest
- type PullRequestError
- type PullRequestList
- type Repositories
- type Repository
Constants ¶
const AuthenticationFailed = "Authentication for %q failed. Make sure to configure GitHub CLI for %q."
Message, when authentication fails.
const ConfigInvalidFormat = "Invalid format %q. Supported formats are: [%s]."
Message, when unsupported format for config provided.
const ConfigNotFound = "No configuration found. Make sure to run 'init' to create initial configuration " +
"or run 'import' to import configuration from stdin."
Message, when config not found.
const ConfigShouldNotExist = "Configuration already exists. " +
"Please run 'update' if you want to update your settings. " +
"Alternatively, run 'remove' if you want to setup from scratch once again."
Message, when config exists, although it should not.
const DefaultExportDestination = "stdout"
Default destination for export.
const DefaultImportSource = "stdin"
Default source for import.
const JSON = "json"
json format
const YAML = "yaml"
yaml format
Variables ¶
This section is empty.
Functions ¶
func ConfigurationExists ¶
func ConfigurationExists() bool
Check if configuration exists within GitHub CLI config.
func GetListOfSupportedFormats ¶
Get list of supported formats.
func GetRepositorySlugFromURL ¶ added in v2.7.1
func GetRepositorySlugFromURL(repo Repository) string
GetRepositorySlugFromURL extracts repository slug from URL.
Types ¶
type Configuration ¶
type Configuration struct { BaseDirectory string `json:"baseDirectory" yaml:"baseDirectory"` AbsoluteDirectoryPath string `json:"directoryPath" yaml:"directoryPath"` Profiles Profiles `json:"profiles,omitempty" yaml:"profiles,omitempty"` Concurrency uint `json:"concurrency" yaml:"concurrency"` SubDirectories bool `json:"subDirectories" yaml:"subDirectories"` SizeLimit uint64 `json:"sizeLimit" yaml:"sizeLimit"` Timeout time.Duration `json:"timeout" yaml:"timeout"` Excluded []string `json:"excluded,omitempty" yaml:"excluded,omitempty"` Included []string `json:"included,omitempty" yaml:"included,omitempty"` Total int64 `json:"total,omitempty" yaml:"total,omitempty"` Repositories Repositories `json:"repositories,omitempty" yaml:"repositories,omitempty"` }
Configuration holds gr configuration data
func (*Configuration) AppendRepositories ¶
func (conf *Configuration) AppendRepositories(user *resources.User, repos ...resources.Repository)
AppendRepositories appends multiple repositories to the configuration and sorts them alphabetically by Directory.
func (Configuration) AuthenticateURL ¶
func (conf Configuration) AuthenticateURL(targetURL *string)
AuthenticateURL encodes username and token into URL. In the case, no matching token can be found for given URL, emit message and exit.
func (Configuration) Cleanup ¶
func (conf Configuration) Cleanup()
Remove local repositories which are not enlisted.
func (Configuration) Display ¶
func (conf Configuration) Display(format, output string, export bool, filters []string)
Display flushes config into Stdout. Supports multiple formats and partial emission (if !export).
func (*Configuration) Edit ¶ added in v2.6.9
func (conf *Configuration) Edit(format, editor string)
Edit configuration.
func (*Configuration) FilterRepositories ¶
func (conf *Configuration) FilterRepositories(repositories *[]resources.Repository)
Filter repositories. Applied filters: included || !excluded || size below x || archived || disabled || !pullPermission || !pushPermission.
func (Configuration) GeneralizeURL ¶
func (conf Configuration) GeneralizeURL(targetURL *string)
GeneralizeURL removes username and token from URL.
func (*Configuration) GetProgressbarDescriptionForVerb ¶
func (conf *Configuration) GetProgressbarDescriptionForVerb(verb string, repo Repository) string
Produce progressbar description considering the length of the repository with the longest name.
func (Configuration) ListUntracked ¶
func (conf Configuration) ListUntracked() (untracked []string)
List local repositories which are not enlisted any longer.
func (*Configuration) Overwrite ¶ added in v2.6.9
func (conf *Configuration) Overwrite(from *Configuration)
Overwrite config.
func (Configuration) Remove ¶
func (conf Configuration) Remove(purge bool)
Remove config. If purge, remove all local repositories.
func (*Configuration) SanitizeDirectory ¶
func (conf *Configuration) SanitizeDirectory()
Transform base directory into UNIx style path and set absolute directory path.
func (Configuration) Save ¶
func (conf Configuration) Save()
Save configuration into GitHub CLI config.
type Profile ¶
type Profile struct { Username string `json:"username" yaml:"username"` Fullname string `json:"fullname" yaml:"fullname"` Email string `json:"email,omitempty" yaml:"email,omitempty"` Host string `json:"host" yaml:"host"` }
Profile holds the context of authenticated user profile.
type Profiles ¶
type Profiles []Profile
type PullRequest ¶ added in v2.7.0
type PullRequest struct { Assignees []string `json:"assignee" yaml:"assignee"` Author string `json:"author" yaml:"author"` Base string `json:"base" yaml:"base"` ClosedAt time.Time `json:"closed_at" yaml:"closed_at"` Error PullRequestError `json:"error" yaml:"error"` Head string `json:"head" yaml:"head"` Labels []string `json:"labels" yaml:"labels"` Number int `json:"number" yaml:"number"` Repository string `json:"repository" yaml:"repository"` State string `json:"state" yaml:"state"` Title string `json:"title" yaml:"title"` URL string `json:"URL" yaml:"URL"` }
PullRequest represents a GitHub pull request.
func PullRequestFromResponse ¶ added in v2.7.1
func PullRequestFromResponse(response resources.PullRequest) PullRequest
PullRequestFromResponse creates a PullRequest from a GitHub API response.
func (PullRequest) Status ¶ added in v2.7.1
func (prl PullRequest) Status() any
Status returns the status of the PullRequest.
type PullRequestError ¶ added in v2.7.1
type PullRequestError string
PullRequestError represents an error that occurred while processing a PullRequest.
func (PullRequestError) Error ¶ added in v2.7.1
func (err PullRequestError) Error() string
Error returns the error message.
type PullRequestList ¶ added in v2.7.0
type PullRequestList []PullRequest
PullRequestList is a list of PullRequest.
func (*PullRequestList) Append ¶ added in v2.7.0
func (prl *PullRequestList) Append(pr PullRequest)
Append appends a PullRequest to the PullRequestList if it is not already in the list.
func (PullRequestList) Browse ¶ added in v2.7.5
func (prl PullRequestList) Browse()
Browse allows to open the URLs of the PullRequests in the default browser.
func (PullRequestList) Has ¶ added in v2.7.0
func (prl PullRequestList) Has(pr PullRequest) bool
Has returns true if the PullRequestList contains the given PullRequest.
type Repositories ¶
type Repositories []Repository
func (*Repositories) Append ¶
func (r *Repositories) Append(repo Repository)
Append repository (only if not present).
func (Repositories) Has ¶
func (r Repositories) Has(repo Repository) bool
Check if repo is enlisted (URL is considered to be unique).
func (Repositories) LongestName ¶
func (r Repositories) LongestName() string
Get the name of the repository with the longest name.
type Repository ¶
type Repository struct { URL string `json:"URL" yaml:"URL"` Directory string `json:"directory" yaml:"directory"` Branch string `json:"branch" yaml:"branch"` ParentURL string `json:"parentURL,omitempty" yaml:"parentURL,omitempty"` Public bool `json:"public,omitempty" yaml:"public,omitempty"` Size string `json:"size" yaml:"size"` }
Repository holds a repository URL and its local directory equivalent.