Skip to content

Commit

Permalink
add window cfg get
Browse files Browse the repository at this point in the history
  • Loading branch information
jryannel committed Sep 8, 2023
1 parent 154c733 commit c1113f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/cfg/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ func Get(key string) any {
return result
}

func GetInt(key string) int {
rw.RLock()
result := v.GetInt(key)
rw.RUnlock()
return result
}

func GetBool(key string) bool {
rw.RLock()
result := v.GetBool(key)
Expand Down
4 changes: 4 additions & 0 deletions pkg/cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (
KeyVersion = "version"
KeyCommit = "commit"
KeyDate = "date"
KeyWindowHeight = "window_height"
KeyWindowWidth = "window_width"
)

const (
Expand Down Expand Up @@ -78,6 +80,8 @@ func NewConfig(cfgDir string) (*viper.Viper, error) {
nv.SetDefault(KeyEditorCommand, "code")
nv.SetDefault(KeyUpdateChannel, "stable")
nv.SetDefault(KeyVersion, "0.0.0")
nv.SetDefault(KeyWindowWidth, 960)
nv.SetDefault(KeyWindowHeight, 720)
// public repo token for github to avoid rate limit
nv.SetDefault(KeyCommit, "none")
nv.SetDefault(KeyDate, "unknown")
Expand Down

0 comments on commit c1113f3

Please sign in to comment.