Skip to content

Commit b8efea0

Browse files
authored
fix: regression for unauthenticated argument handling (#56)
A core function of the notehub CLI is to do things like find out what version of the utility you're running, or setting or clearing out of the "current notehub". Since adding the browser-based functionality, the CLI couldn't do these functions without validating credentials: notehub -version notehub -hub - notehub -hub ray.blues.tools This PR fixes the regression.
1 parent c8bde4c commit b8efea0

File tree

4 files changed

+144
-91
lines changed

4 files changed

+144
-91
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ require (
2323
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
2424
github.com/rivo/uniseg v0.4.7 // indirect
2525
github.com/shirou/gopsutil/v3 v3.24.4 // indirect
26+
github.com/shoenig/go-m1cpu v0.1.7 // indirect
2627
github.com/tklauser/go-sysconf v0.3.14 // indirect
2728
go.bug.st/serial v1.6.2
2829
golang.org/x/sys v0.20.0 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ github.com/shirou/gopsutil/v3 v3.24.4 h1:dEHgzZXt4LMNm+oYELpzl9YCqV65Yr/6SfrvgRB
5454
github.com/shirou/gopsutil/v3 v3.24.4/go.mod h1:lTd2mdiOspcqLgAnr9/nGi71NkeMpWKdmhuxm9GusH8=
5555
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
5656
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
57+
github.com/shoenig/go-m1cpu v0.1.7 h1:C76Yd0ObKR82W4vhfjZiCp0HxcSZ8Nqd84v+HZ0qyI0=
58+
github.com/shoenig/go-m1cpu v0.1.7/go.mod h1:KkDOw6m3ZJQAPHbrzkZki4hnx+pDRR1Lo+ldA56wD5w=
5759
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
5860
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
61+
github.com/shoenig/test v1.7.0 h1:eWcHtTXa6QLnBvm0jgEabMRN/uJ4DMV3M8xUGgRkZmk=
62+
github.com/shoenig/test v1.7.0/go.mod h1:UxJ6u/x2v/TNs/LoLxBNJRV9DiwBBKYxXSyczsBHFoI=
5963
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
6064
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
6165
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=

lib/config.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ func GetConfig() (*ConfigSettings, error) {
251251
config = defaultConfig()
252252
}
253253
}
254+
if config.IPort == nil {
255+
config.IPort = make(map[string]ConfigPort)
256+
}
257+
if config.HubCreds == nil {
258+
config.HubCreds = make(map[string]ConfigCreds)
259+
}
254260
return config, nil
255261
}
256262

@@ -278,6 +284,12 @@ func ConfigRead() error {
278284
return fmt.Errorf("can't parse %s: %s", configPath, err)
279285
}
280286
config = &newConfig
287+
if config.IPort == nil {
288+
config.IPort = make(map[string]ConfigPort)
289+
}
290+
if config.HubCreds == nil {
291+
config.HubCreds = make(map[string]ConfigCreds)
292+
}
281293

282294
return nil
283295
}
@@ -378,8 +390,6 @@ func FlagParse(notecardFlags bool, notehubFlags bool) (err error) {
378390
if err := config.Write(); err != nil {
379391
return fmt.Errorf("could not write config file: %w", err)
380392
}
381-
fmt.Printf("configuration file saved\n\n")
382-
config.Print()
383393
}
384394

385395
// Override, just for this session, with env vars

0 commit comments

Comments
 (0)