Documentation
¶
Index ¶
- Constants
- Variables
- func ActiveProject(v *viper.Viper, override string) string
- func ApplyProject(v *viper.Viper, name string) error
- func DefaultProjectName(projectKey string) string
- func Exists(file string) bool
- func GenerateProject(client *jira.Client, project, board string) (map[string]any, error)
- func Path(flagValue string) (string, error)
- func ValidateProjectName(name string) error
- type File
- func (f *File) Delete(keys ...string) bool
- func (f *File) DeleteProject(name string) error
- func (f *File) Get(keys ...string) *yaml.Node
- func (f *File) GetString(keys ...string) string
- func (f *File) HasProject(name string) bool
- func (f *File) Keys(keys ...string) []string
- func (f *File) Path() string
- func (f *File) Projects() []SavedProject
- func (f *File) RenameProject(from, to string) error
- func (f *File) Resolve(selector string) string
- func (f *File) Save() error
- func (f *File) Set(value any, keys ...string) error
- func (f *File) StringMap(keys ...string) map[string]string
- func (f *File) UseProject(name string) (string, error)
- type JiraCLIConfig
- type JiraCLIConfigGenerator
- type JiraCLIMTLSConfig
- type SavedProject
Constants ¶
const ( // Dir is the jt config directory. Dir = "jt" // FileName is the jt config file name. FileName = "config" // FileType is the jt config file extension. FileType = "yml" )
const ( // KeyProjects holds the named projects. KeyProjects = "projects" // KeyCurrentProject is the active project name. KeyCurrentProject = "current_project" // KeyPreviousProject is the project active before the last switch, used by `project -`. KeyPreviousProject = "previous_project" // KeyAliases holds user-defined command aliases. KeyAliases = "aliases" // KeySavedQueries holds named JQL queries. KeySavedQueries = "saved_queries" )
Variables ¶
var ( // ErrSkip is returned when a user skips the config generation. ErrSkip = fmt.Errorf("skipping config generation") // ErrUnexpectedResponseFormat is returned if the response data is in unexpected format. ErrUnexpectedResponseFormat = fmt.Errorf("unexpected response format") )
var ErrNoConfig = errors.New("config file not found, run 'jt init' to create one")
ErrNoConfig is returned when no config file exists at the resolved path.
Functions ¶
func ActiveProject ¶
ActiveProject returns the project to use: override (flag/env) if set, otherwise current_project from the config.
func ApplyProject ¶
ApplyProject overlays projects.<name> onto the top-level config so every existing command (which reads project.key, board.id, issue.types, ...) transparently uses the project. Project keys replace the top-level keys wholesale rather than deep-merging, so a project without e.g. board.type does not inherit the default board's type. The overlay is loaded into viper's config layer, so command-line flags such as --project still win.
func DefaultProjectName ¶
DefaultProjectName derives a project name from a project key.
func GenerateProject ¶
GenerateProject resolves a project (and optionally a board) against the server and returns the value to store under contexts.<name>. Empty project or board values are asked for interactively, reusing the init pickers.
func Path ¶
Path resolves the config file location: explicit flag value first, then JT_CONFIG_FILE (or JIRA_CONFIG_FILE), then ~/.config/jt/config.yml.
func ValidateProjectName ¶
ValidateProjectName rejects names that would not round-trip as YAML keys or that collide with the `project -` shorthand.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a YAML config file edited in place. It works on the yaml.Node tree so that comments and key order written by the user survive a Save.
func LoadCurrent ¶
LoadCurrent loads the config file in use by this invocation (as resolved by the root command), falling back to the default location.
func (*File) DeleteProject ¶
DeleteProject removes a project. Deleting the current project clears current_project so commands fall back to the top-level project.
func (*File) HasProject ¶
HasProject reports whether name is defined.
func (*File) Projects ¶
func (f *File) Projects() []SavedProject
Projects lists the saved projects defined in the file.
func (*File) RenameProject ¶
RenameProject renames a project, keeping current/previous pointers valid.
func (*File) Resolve ¶
Resolve maps a selector to a saved project name: an exact name wins, then a case-insensitive Jira key match. It returns "" if nothing matches.
func (*File) Save ¶
Save writes the file atomically (temp file + rename), keeping it 0600 because it lives next to credentials-adjacent settings.
type JiraCLIConfig ¶
type JiraCLIConfig struct {
Installation string
Server string
AuthType string
Login string
Project string
Board string
Force bool
Insecure bool
MTLS JiraCLIMTLSConfig
}
JiraCLIConfig is a Jira CLI config.
type JiraCLIConfigGenerator ¶
type JiraCLIConfigGenerator struct {
// contains filtered or unexported fields
}
JiraCLIConfigGenerator is a Jira CLI config generator.
func NewJiraCLIConfigGenerator ¶
func NewJiraCLIConfigGenerator(cfg *JiraCLIConfig) *JiraCLIConfigGenerator
NewJiraCLIConfigGenerator creates a new Jira CLI config.
func (*JiraCLIConfigGenerator) Generate ¶
func (c *JiraCLIConfigGenerator) Generate() (string, error)
Generate generates the config file.
type JiraCLIMTLSConfig ¶
JiraCLIMTLSConfig is an authtype specific config.