Skip to content

Commit

Permalink
Implement default config values (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethack authored Dec 19, 2018
1 parent 03232ac commit fcfb31b
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 236 deletions.
107 changes: 23 additions & 84 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@
[[constraint]]
branch = "v2"
name = "gopkg.in/yaml.v2"

[[constraint]]
name = "github.com/creasty/defaults"
version = "1.2.1"
4 changes: 2 additions & 2 deletions commands/test-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func testConfiguration(c *cli.Context) error {
// First, print out the config as it was parsed
conf, err := config.LoadConfig(c.String("config"))
if err != nil {
fmt.Fprintf(os.Stdout, "Failed to config, exiting")
panic(err)
fmt.Fprintf(os.Stdout, "Failed to config: %s\n", err.Error())
os.Exit(-1)
}

staticConfig, err := yaml.Marshal(conf.S)
Expand Down
10 changes: 1 addition & 9 deletions commands/update-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,11 @@ func GetVersionPrinter() func(*cli.Context) {
//returns a string indicating the new version if available
func updateCheck(configFile string) string {
res := resources.InitResources(configFile)
deltaPtr := res.Config.S.UserConfig.UpdateCheckFrequency
delta := res.Config.S.UserConfig.UpdateCheckFrequency
var newVersion semver.Version
var err error
var delta int
var timestamp time.Time

if deltaPtr == nil {
delta = 14
} else {
delta = *deltaPtr
}

if delta <= 0 {
return ""
}
Expand Down Expand Up @@ -108,7 +101,6 @@ func getRemoteVersion() (semver.Version, error) {
// The return value is printed regardless so, "" is returned on errror.
//func informUser( verStr string, index int ) string {
func informUser(local semver.Version, remote semver.Version) string {

return fmt.Sprintf(informFmtStr,
versions[versionDiffIndex(remote, local)],
fmt.Sprint(remote))
Expand Down
Loading

0 comments on commit fcfb31b

Please sign in to comment.