goxc: github.com/laher/goxc/config Index | Files

package config

import "github.com/laher/goxc/config"

config package handles invocation settings for goxc, which can be set using a combination of cli flags plus json-based config files.

Index

Package Files

buildsettings.go cli.go defaults.go json.go settings.go sliceflags.go

Constants

const (
    GOXC_CONFIG_VERSION = "0.9"
)

Variables

var GOXC_CONFIG_SUPPORTED = []string{"0.5.0", "0.6", "0.8", "0.9"}

func FillBuildSettingsDefaults Uses

func FillBuildSettingsDefaults(bs *BuildSettings)

func FillSettingsDefaults Uses

func FillSettingsDefaults(settings *Settings, workingDirectory string)

TODO fulfil all defaults

func ParseCliTasksAndTaskSettings Uses

func ParseCliTasksAndTaskSettings(args []string) ([]string, map[string]map[string]interface{}, error)

tasks (and task settings) are defined as args after the main flags

func StripEmpties Uses

func StripEmpties(rawJson []byte, verbose bool) ([]byte, error)

0.6 DEPRECATED (in favour of omitempty tag)

func WriteJsonConfig Uses

func WriteJsonConfig(dir string, settings Settings, configName string, isLocal bool) error

type BuildSettings Uses

type BuildSettings struct {
    //GoRoot string `json:"-"` //Made *not* settable in settings file. Only at runtime.
    //GoVersion string `json:",omitempty"` //hmm. Should I encourage this?
    Processors    *int                    `json:",omitempty"`
    Race          *bool                   `json:",omitempty"`
    Verbose       *bool                   `json:",omitempty"`
    PrintCommands *bool                   `json:",omitempty"`
    CcFlags       *string                 `json:",omitempty"`
    Compiler      *string                 `json:",omitempty"`
    GccGoFlags    *string                 `json:",omitempty"`
    GcFlags       *string                 `json:",omitempty"`
    InstallSuffix *string                 `json:",omitempty"`
    LdFlags       *string                 `json:",omitempty"`
    LdFlagsXVars  *map[string]interface{} `json:",omitempty"`
    Tags          *string                 `json:",omitempty"`
    ExtraArgs     []string                `json:",omitempty"`
}

func (BuildSettings) Equals Uses

func (this BuildSettings) Equals(that BuildSettings) bool

func (BuildSettings) IsEmpty Uses

func (this BuildSettings) IsEmpty() bool

type Settings Uses

type Settings struct {
    AppName       string `json:",omitempty"`
    ArtifactsDest string `json:",omitempty"`
    //0.13.x. If this starts with a FileSeparator then ignore top dir
    OutPath string `json:",omitempty"`

    //0.2.0 Tasks replaces IsBuildToolChain bool
    //0.5.0 Tasks is a much longer list.
    Tasks []string `json:",omitempty"`

    //0.5.0 adding exclusions. Easier for dealing with aliases. (e.g. Tasks=[default], TasksExclude=[rmbin] is easier than specifying individual tasks)
    TasksExclude []string `json:",omitempty"`

    //0.5.0 adding extra tasks.
    TasksAppend []string `json:",omitempty"`
    //0.9.9 adding 'prepend'
    TasksPrepend []string `json:",omitempty"`

    //0.6 complement Os/Arch with BuildConstraints
    Arch string `json:",omitempty"`
    Os   string `json:",omitempty"`
    //NEW 0.5.5 - implemented 0.5.7
    BuildConstraints string `json:",omitempty"`

    //0.9 changed from struct to ResourcesInclude & ResourcesExclude
    ResourcesInclude string `json:",omitempty"`
    ResourcesExclude string `json:",omitempty"`

    //0.10.x source exclusion
    MainDirsExclude string `json:",omitempty"`
    //0.13.x source exclusion (source dirs)
    SourceDirsExclude string `json:",omitempty"`

    //versioning
    PackageVersion string `json:",omitempty"`
    BranchName     string `json:",omitempty"`
    PrereleaseInfo string `json:",omitempty"`
    BuildName      string `json:",omitempty"`

    //0.2.0 Verbosity replaces Verbose bool
    Verbosity string `json:",omitempty"` // none/debug/

    //TaskSettings map[string]map[string]interface{}
    TaskSettings map[string]map[string]interface{} `json:",omitempty"`

    //DEPRECATED (since v0.9. See GoxcConfigVersion)
    FormatVersion string `json:",omitempty"`

    //v0.9, to replace 'FormatVersion'
    GoxcConfigVersion string `json:"ConfigVersion,omitempty"`

    BuildSettings *BuildSettings `json:",omitempty"`

    GoRoot string `json:"-"` //only settable by a flag

    //v0.10.x
    Env []string `json:",omitempty"`
}

Invocation settings

func LoadJsonConfigOverrideable Uses

func LoadJsonConfigOverrideable(dir string, configName string, isRead, isWriteLocal, verbose bool) (Settings, error)

Loads a config file and merges results with any 'override' files. 0.8 using new inheritance rules. More flexibility, particular for people wanting different rules for different platforms 0.10.x adding parameter isWriteLocal

func LoadJsonConfigs Uses

func LoadJsonConfigs(dir string, configs []string, verbose bool) (Settings, error)

func Merge Uses

func Merge(high Settings, low Settings) Settings

DEPRECATED!! Merge settings together with priority. TODO: deprecate in favour of map merge.

func (*Settings) GetFullVersionName Uses

func (settings *Settings) GetFullVersionName() string

Builds version name from PackageVersion, BranchName, PrereleaseInfo, BuildName This breakdown is mainly based on 'semantic versioning' See http://semver.org/ The difference being that you can specify a branch name (which becomes part of the 'prerelease info' as named by semver)

func (*Settings) GetTaskSetting Uses

func (s *Settings) GetTaskSetting(taskName, settingName string) interface{}

func (*Settings) GetTaskSettingBool Uses

func (s *Settings) GetTaskSettingBool(taskName, settingName string) bool

func (*Settings) GetTaskSettingInt Uses

func (s *Settings) GetTaskSettingInt(taskName, settingName string, defaultValue int) int

func (*Settings) GetTaskSettingMap Uses

func (s *Settings) GetTaskSettingMap(taskName, settingName string) map[string]interface{}

func (*Settings) GetTaskSettingString Uses

func (s *Settings) GetTaskSettingString(taskName, settingName string) string

func (*Settings) GetTaskSettingStringSlice Uses

func (s *Settings) GetTaskSettingStringSlice(taskName, settingName string) []string

func (*Settings) IsQuiet Uses

func (s *Settings) IsQuiet() bool

func (*Settings) IsTask Uses

func (s *Settings) IsTask(taskName string) bool

func (*Settings) IsVerbose Uses

func (s *Settings) IsVerbose() bool

func (*Settings) MergeAliasedTaskSettings Uses

func (s *Settings) MergeAliasedTaskSettings(aliases map[string][]string)

this helps whenever a 'task' gets refactored to become an 'alias' (e.g. 'pkg-build' task renamed to 'deb', and 'pkg-build' became a task alias) note that the task settings take precedence over the alias' settings.

func (*Settings) SetTaskSetting Uses

func (s *Settings) SetTaskSetting(taskName, settingName string, value interface{})

type Strslice Uses

type Strslice []string

Define a type named "intslice" as a slice of ints

func (*Strslice) Set Uses

func (i *Strslice) Set(value string) error

The second method is Set(value string) error

func (*Strslice) String Uses

func (i *Strslice) String() string

Now, for our new type, implement the two methods of the flag.Value interface... The first method is String() string

Package config imports 11 packages (graph) and is imported by 13 packages. Updated 2016-07-22. Refresh now. Tools for package owners.