config

package
v4.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppContextPathFunc = AppContextPath

Functions

func AppContextPath added in v4.0.2

func AppContextPath(envar string, getDir func() (string, error), rel ...string) (string, error)

AppContextPath returns the path to the app's configuration file.

If the environment variable `envar` is set, it returns that. Specify a function to get the parent directory where the file will be placed, such as os.UserConfigDir. The `rel` is the relative path to the file from the dir.

It will make the path that is formed as {getDir()}/{AppName=gogh}/{rel...}`

func HookDir added in v4.0.2

func HookDir() (string, error)

HookDir returns the path to the hook directory.

func LoadAlternative

func LoadAlternative[T store.Content](ctx context.Context, initial func() T, loaders ...store.Loader[T]) (T, error)

LoadAlternative loads a value of type T using the provided loaders. It tries each loader in order until one succeeds or all fail. If all loaders fail, it returns the initial value provided by the initial function.

func LocationFormatter

func LocationFormatter(v string) (repository.LocationFormat, error)

func OverlayDir added in v4.0.2

func OverlayDir() (string, error)

OverlayDir returns the path to the overlay directory.

func ScriptDir added in v4.0.2

func ScriptDir() (string, error)

ScriptDir returns the path to the script directory.

Types

type BundleDumpFlags

type BundleDumpFlags struct {
	File string `yaml:"file,omitempty" toml:"file,omitempty"`
}

BundleDumpFlags is a struct that contains flags for dumping a bundle.

type BundleRestoreFlags

type BundleRestoreFlags struct {
	File              string        `yaml:"file,omitempty" toml:"file,omitempty"`
	CloneRetryTimeout time.Duration `yaml:"cloneRetryTimeout,omitempty" toml:"clone-retry-timeout,omitempty"`
	CloneRetryLimit   int           `yaml:"cloneRetryLimit,omitempty" toml:"clone-retry-limit,omitempty"`
	DryRun            bool          `yaml:"-" toml:"-"`
}

BundleRestoreFlags is a struct that contains flags for restoring a bundle.

type CloneFlags

type CloneFlags struct {
	CloneRetryTimeout time.Duration `yaml:"cloneRetryTimeout,omitempty" toml:"clone-retry-timeout,omitempty"`
	DryRun            bool          `yaml:"-" toml:"-"`
}

CloneFlags is a struct that contains flags for cloning a repository.

type CreateFlags

type CreateFlags struct {
	Template            string        `yaml:"template,omitempty" toml:"template,omitempty"`
	Description         string        `yaml:"-" toml:"-"`
	Homepage            string        `yaml:"-" toml:"-"`
	LicenseTemplate     string        `yaml:"licenseTemplate,omitempty" toml:"license-template,omitempty"`
	GitignoreTemplate   string        `yaml:"gitignoreTemplate,omitempty" toml:"gitignore-template,omitempty"`
	CloneRetryTimeout   time.Duration `yaml:"cloneRetryTimeout,omitempty" toml:"clone-retry-timeout,omitempty"`
	CloneRetryLimit     int           `yaml:"cloneRetryLimit,omitempty" toml:"clone-retry-limit,omitempty"`
	DisableWiki         bool          `yaml:"disableWiki,omitempty" toml:"disable-wiki,omitempty"`
	DisableDownloads    bool          `yaml:"disableDownloads,omitempty" toml:"disable-downloads,omitempty"`
	IsTemplate          bool          `yaml:"-" toml:"-"`
	AutoInit            bool          `yaml:"autoInit,omitempty" toml:"auto-init,omitempty"`
	DisableProjects     bool          `yaml:"disableProjects,omitempty" toml:"disable-projects,omitempty"`
	DisableIssues       bool          `yaml:"disableIssues,omitempty" toml:"disable-issues,omitempty"`
	PreventSquashMerge  bool          `yaml:"preventSquashMerge,omitempty" toml:"prevent-squash-merge,omitempty"`
	PreventMergeCommit  bool          `yaml:"preventMergeCommit,omitempty" toml:"prevent-merge-commit,omitempty"`
	PreventRebaseMerge  bool          `yaml:"preventRebaseMerge,omitempty" toml:"prevent-rebase-merge,omitempty"`
	DeleteBranchOnMerge bool          `yaml:"deleteBranchOnMerge,omitempty" toml:"delete-branch-on-merge,omitempty"`
	Private             bool          `yaml:"private,omitempty" toml:"private,omitempty"`
	IncludeAllBranches  bool          `yaml:"includeAllBranches,omitempty" toml:"include-all-branches,omitempty"`
	DryRun              bool          `yaml:"-" toml:"-"`
}

CreateFlags is a struct that contains flags for creating a repository.

type CwdFlags

type CwdFlags struct {
	Format string `yaml:"format,omitempty" toml:"format,omitempty"`
}

CwdFlags is a struct that contains flags for the cwd command.

type DefaultNameStore

type DefaultNameStore struct{}

func NewDefaultNameStore

func NewDefaultNameStore() *DefaultNameStore

func (*DefaultNameStore) Load

Load implements repository.DefaultNameRepository.

func (*DefaultNameStore) Save

Save implements repository.DefaultNameRepository.

func (*DefaultNameStore) Source

func (*DefaultNameStore) Source() (string, error)

type DefaultNameStoreV0

type DefaultNameStoreV0 struct{}

func NewDefaultNameStoreV0

func NewDefaultNameStoreV0() *DefaultNameStoreV0

func (*DefaultNameStoreV0) Load

Load implements store.Loader.

func (*DefaultNameStoreV0) Source

func (*DefaultNameStoreV0) Source() (string, error)

type ExtraStore added in v4.0.2

type ExtraStore struct{}

ExtraStore stores extra configuration

func NewExtraStore added in v4.0.2

func NewExtraStore() *ExtraStore

NewExtraStore creates a new extra store

func (*ExtraStore) Load added in v4.0.2

func (s *ExtraStore) Load(ctx context.Context, initial func() extra.ExtraService) (extra.ExtraService, error)

Load loads extra configuration

func (*ExtraStore) Save added in v4.0.2

func (s *ExtraStore) Save(ctx context.Context, svc extra.ExtraService, force bool) error

Save saves extra configuration

func (*ExtraStore) Source added in v4.0.2

func (s *ExtraStore) Source() (string, error)

Source returns the path to the extra store file

type Flags

type Flags struct {
	RawHasChanges bool               `yaml:"-" toml:"-"` // RawHasChanges is used to track if there are any changes in the flags.
	BundleDump    BundleDumpFlags    `yaml:"bundleDump,omitempty" toml:"bundle-dump,omitempty"`
	BundleRestore BundleRestoreFlags `yaml:"bundleRestore,omitempty" toml:"bundle-restore,omitempty"`
	Clone         CloneFlags         `yaml:"clone,omitempty" toml:"clone"`
	List          ListFlags          `yaml:"list,omitempty" toml:"list,omitempty"`
	Cwd           CwdFlags           `yaml:"cwd,omitempty" toml:"cwd,omitempty"`
	Create        CreateFlags        `yaml:"create,omitempty" toml:"create,omitempty"`
	Repos         ReposFlags         `yaml:"repos,omitempty" toml:"repos,omitempty"`
	Fork          ForkFlags          `yaml:"fork,omitempty" toml:"fork,omitempty"`
}

Flags is a struct that contains all the flags for the application.

func DefaultFlags

func DefaultFlags() *Flags

func (*Flags) HasChanges

func (f *Flags) HasChanges() bool

HasChanges always returns false because Flags does not support saving.

func (*Flags) MarkSaved

func (f *Flags) MarkSaved()

MarkSaved is a no-op function. It does not save any changes to the Flags struct.

type FlagsStore

type FlagsStore struct{}

FlagsStore is a store for flags.

func NewFlagsStore

func NewFlagsStore() *FlagsStore

NewFlagsStore creates a new FlagsStore.

func (*FlagsStore) Load

func (s *FlagsStore) Load(ctx context.Context, initial func() *Flags) (*Flags, error)

Load implements store.Loader

func (*FlagsStore) Save added in v4.0.2

func (d *FlagsStore) Save(ctx context.Context, flags *Flags, force bool) error

Save implements repository.FlagsRepository.

func (*FlagsStore) Source

func (s *FlagsStore) Source() (string, error)

type FlagsStoreV0

type FlagsStoreV0 struct{}

func NewFlagsStoreV0

func NewFlagsStoreV0() *FlagsStoreV0

func (*FlagsStoreV0) Load

func (d *FlagsStoreV0) Load(ctx context.Context, initial func() *Flags) (*Flags, error)

Load implements store.Loader

func (*FlagsStoreV0) Source

func (d *FlagsStoreV0) Source() (string, error)

Source implements store.Loader

type ForkFlags

type ForkFlags struct {
	To                string        `yaml:"-" toml:"-"`
	DefaultBranchOnly bool          `yaml:"defaultBranchOnly,omitempty" toml:"default-branch-only,omitempty"`
	CloneRetryTimeout time.Duration `yaml:"cloneRetryTimeout,omitempty" toml:"clone-retry-timeout,omitempty"`
	CloneRetryLimit   int           `yaml:"cloneRetryLimit,omitempty" toml:"clone-retry-limit,omitempty"`
}

ForkFlags is a struct that contains flags for forking a repository.

type HookStore added in v4.0.2

type HookStore struct{}

func NewHookStore added in v4.0.2

func NewHookStore() *HookStore

func (*HookStore) Load added in v4.0.2

func (s *HookStore) Load(ctx context.Context, initial func() hook.HookService) (hook.HookService, error)

func (*HookStore) Save added in v4.0.2

func (s *HookStore) Save(ctx context.Context, svc hook.HookService, force bool) error

func (*HookStore) Source added in v4.0.2

func (s *HookStore) Source() (string, error)

type ListFlags

type ListFlags struct {
	Limit    int      `yaml:"limit,omitempty" toml:"limit,omitempty"`
	Patterns []string `yaml:"-" toml:"-"`
	Format   string   `yaml:"format,omitempty" toml:"format,omitempty"`
	Primary  bool     `yaml:"primary,omitempty" toml:"primary,omitempty"`
}

ListFlags is a struct that contains flags for listing repositories.

type OverlayContentStore added in v4.0.2

type OverlayContentStore struct{}

func NewOverlayContentStore added in v4.0.2

func NewOverlayContentStore() *OverlayContentStore

func (*OverlayContentStore) Open added in v4.0.2

func (cs *OverlayContentStore) Open(ctx context.Context, overlayID string) (io.ReadCloser, error)

func (*OverlayContentStore) Remove added in v4.0.2

func (cs *OverlayContentStore) Remove(ctx context.Context, overlayID string) error

func (*OverlayContentStore) Save added in v4.0.2

func (cs *OverlayContentStore) Save(ctx context.Context, overlayID string, content io.Reader) error

func (*OverlayContentStore) Source added in v4.0.2

func (*OverlayContentStore) Source() (string, error)

type OverlayStore added in v4.0.2

type OverlayStore struct{}

OverlayStore implements overlay.OverlayStore and persists overlays as TOML.

func NewOverlayStore added in v4.0.2

func NewOverlayStore() *OverlayStore

func (*OverlayStore) Load added in v4.0.2

func (*OverlayStore) Save added in v4.0.2

func (s *OverlayStore) Save(ctx context.Context, svc overlay.OverlayService, force bool) error

func (*OverlayStore) Source added in v4.0.2

func (s *OverlayStore) Source() (string, error)

type ReposFlags

type ReposFlags struct {
	Limit    int      `yaml:"limit,omitempty" toml:"limit,omitempty"`
	Privacy  string   `yaml:"privacy,omitempty" toml:"privacy,omitempty"`
	Fork     string   `yaml:"fork,omitempty" toml:"fork,omitempty"`
	Archive  string   `yaml:"archived,omitempty" toml:"archived,omitempty"`
	Format   string   `yaml:"format,omitempty" toml:"format,omitempty"`
	Color    string   `yaml:"color,omitempty" toml:"color,omitempty"`
	Relation []string `yaml:"relation,omitempty" toml:"relation,omitempty"`
	Sort     string   `yaml:"sort,omitempty" toml:"sort,omitempty"`
	Order    string   `yaml:"order,omitempty" toml:"order,omitempty"`
}

ReposFlags is a struct that contains flags for the repos command.

type ScriptSourceStore added in v4.0.2

type ScriptSourceStore struct{}

func NewScriptSourceStore added in v4.0.2

func NewScriptSourceStore() *ScriptSourceStore

func (*ScriptSourceStore) Open added in v4.0.2

func (cs *ScriptSourceStore) Open(ctx context.Context, scriptID string) (io.ReadCloser, error)

func (*ScriptSourceStore) Remove added in v4.0.2

func (cs *ScriptSourceStore) Remove(ctx context.Context, scriptID string) error

func (*ScriptSourceStore) Save added in v4.0.2

func (cs *ScriptSourceStore) Save(ctx context.Context, scriptID string, content io.Reader) error

func (*ScriptSourceStore) Source added in v4.0.2

func (*ScriptSourceStore) Source() (string, error)

type ScriptStore added in v4.0.2

type ScriptStore struct{}

func NewScriptStore added in v4.0.2

func NewScriptStore() *ScriptStore

func (*ScriptStore) Load added in v4.0.2

func (s *ScriptStore) Load(ctx context.Context, initial func() script.ScriptService) (script.ScriptService, error)

func (*ScriptStore) Save added in v4.0.2

func (s *ScriptStore) Save(ctx context.Context, svc script.ScriptService, force bool) error

func (*ScriptStore) Source added in v4.0.2

func (s *ScriptStore) Source() (string, error)

type TokenStore

type TokenStore struct{}

TokenStore is a repository for managing token configuration.

func NewTokenStore

func NewTokenStore() *TokenStore

func (*TokenStore) Load

func (d *TokenStore) Load(ctx context.Context, initial func() auth.TokenService) (auth.TokenService, error)

Load implements store.Store.

func (*TokenStore) Save

func (d *TokenStore) Save(ctx context.Context, ds auth.TokenService, force bool) error

Save implements store.Store.

func (*TokenStore) Source

func (d *TokenStore) Source() (string, error)

type TokenStoreV0

type TokenStoreV0 struct{}

TokenStoreV0 is a repository for managing token configuration.

func NewTokenStoreV0

func NewTokenStoreV0() *TokenStoreV0

func (*TokenStoreV0) Load

func (d *TokenStoreV0) Load(ctx context.Context, initial func() auth.TokenService) (auth.TokenService, error)

Load implements store.Loader

func (*TokenStoreV0) Source

func (*TokenStoreV0) Source() (string, error)

type WorkspaceStore

type WorkspaceStore struct{}

WorkspaceStore is a repository for managing workspace configuration.

func NewWorkspaceStore

func NewWorkspaceStore() *WorkspaceStore

NewWorkspaceStore creates a new WorkspaceStore instance.

func (*WorkspaceStore) Load

Load implements store.Store.

func (*WorkspaceStore) Save

Save implements workspace.WorkspaceRepository.

func (*WorkspaceStore) Source

func (*WorkspaceStore) Source() (string, error)

type WorkspaceStoreV0

type WorkspaceStoreV0 struct{}

WorkspaceStoreV0 is a repository for managing workspace configuration.

func NewWorkspaceStoreV0

func NewWorkspaceStoreV0() *WorkspaceStoreV0

NewWorkspaceStoreV0 creates a new WorkspaceStore instance.

func (*WorkspaceStoreV0) Load

Load implements store.Loader

func (*WorkspaceStoreV0) Source

func (*WorkspaceStoreV0) Source() (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址