Documentation
¶
Index ¶
- Variables
- func AuthFlowWithConfig(cfg Config, hostname, notice string, additionalScopes []string) (string, error)
- func ConfigDir() string
- func ConfigFile() string
- func IsGitHubApp(id string) bool
- func NewBlankRoot() *yaml.Node
- func StubBackupConfig() func()
- func StubConfig(main, hosts string) func()
- func StubWriteConfig(wc io.Writer, wh io.Writer) func()
- type AliasConfig
- type Config
- type ConfigEntry
- type ConfigMap
- type HostConfig
- type NotFoundError
Constants ¶
This section is empty.
Variables ¶
View Source
var BackupConfigFile = func(filename string) error { return os.Rename(filename, filename+".bak") }
View Source
var ReadConfigFile = func(filename string) ([]byte, error) { f, err := os.Open(filename) if err != nil { return nil, pathError(err) } defer f.Close() data, err := ioutil.ReadAll(f) if err != nil { return nil, err } return data, nil }
View Source
var WriteConfigFile = func(filename string, data []byte) error { err := os.MkdirAll(path.Dir(filename), 0771) if err != nil { return pathError(err) } cfgFile, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } defer cfgFile.Close() n, err := cfgFile.Write(data) if err == nil && n < len(data) { err = io.ErrShortWrite } return err }
Functions ¶
func AuthFlowWithConfig ¶ added in v0.10.0
func ConfigFile ¶
func ConfigFile() string
func IsGitHubApp ¶ added in v0.8.0
IsGitHubApp reports whether an OAuth app is "GitHub CLI" or "GitHub CLI (dev)"
func NewBlankRoot ¶ added in v0.11.0
func NewBlankRoot() *yaml.Node
func StubBackupConfig ¶
func StubBackupConfig() func()
func StubConfig ¶
func StubConfig(main, hosts string) func()
Types ¶
type AliasConfig ¶ added in v0.10.0
func (*AliasConfig) Add ¶ added in v0.10.0
func (a *AliasConfig) Add(alias, expansion string) error
func (*AliasConfig) All ¶ added in v0.10.0
func (a *AliasConfig) All() map[string]string
func (*AliasConfig) Delete ¶ added in v0.10.0
func (a *AliasConfig) Delete(alias string) error
type Config ¶
type Config interface {
Get(string, string) (string, error)
Set(string, string, string) error
UnsetHost(string)
Hosts() ([]string, error)
Aliases() (*AliasConfig, error)
Write() error
}
This interface describes interacting with some persistent configuration for gh.
func NewBlankConfig ¶ added in v0.10.0
func NewBlankConfig() Config
NewBlankConfig initializes a config file pre-populated with comments and default values
func NewFromString ¶ added in v0.12.0
NewFromString initializes a Config from a yaml string
func ParseConfig ¶
func ParseDefaultConfig ¶
type ConfigEntry ¶ added in v0.10.0
type ConfigEntry struct {
KeyNode *yaml.Node
ValueNode *yaml.Node
Index int
}
type ConfigMap ¶
type ConfigMap struct {
Root *yaml.Node
}
This type implements a low-level get/set config that is backed by an in-memory tree of Yaml nodes. It allows us to interact with a yaml-based config programmatically, preserving any comments that were present when the yaml was parsed.
func (*ConfigMap) FindEntry ¶
func (cm *ConfigMap) FindEntry(key string) (ce *ConfigEntry, err error)
func (*ConfigMap) RemoveEntry ¶ added in v0.10.0
func (*ConfigMap) SetStringValue ¶
type HostConfig ¶
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.