Compare commits
3 Commits
e0c8825949
...
7d0620fe3e
Author | SHA1 | Date | |
---|---|---|---|
7d0620fe3e | |||
3115c5feef | |||
10ca4f4671 |
8
actor.go
8
actor.go
@ -29,6 +29,14 @@ type Actor interface {
|
|||||||
Type() string
|
Type() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Named is any object with a name.
|
||||||
|
type Named() string {
|
||||||
|
// Name returns the name. This doesn't need to be the same as Type. It
|
||||||
|
// must return the same string every time. It is used to differentiate
|
||||||
|
// actors of the same type in logs.
|
||||||
|
Name() string
|
||||||
|
}
|
||||||
|
|
||||||
// FlagAdder is any object that can add [Flag]s to a [FlagSet]. Actors which
|
// FlagAdder is any object that can add [Flag]s to a [FlagSet]. Actors which
|
||||||
// implement this interface will be called upon to add flags during and only
|
// implement this interface will be called upon to add flags during and only
|
||||||
// during the flag parsing phase.
|
// during the flag parsing phase.
|
||||||
|
2
ini.go
2
ini.go
@ -162,7 +162,7 @@ func configFiles(program string) ([]string, error) {
|
|||||||
userConfig, err := os.UserConfigDir()
|
userConfig, err := os.UserConfigDir()
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
return []string {
|
return []string {
|
||||||
filepath.Join("/etc", program),
|
filepath.Join("/etc", program, program + ".conf"),
|
||||||
filepath.Join(userConfig, program),
|
filepath.Join(userConfig, program),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
6
util.go
6
util.go
@ -77,7 +77,11 @@ func logActors (actors iter.Seq[Actor]) {
|
|||||||
}
|
}
|
||||||
types := make(map[string] int)
|
types := make(map[string] int)
|
||||||
for actor := range actors {
|
for actor := range actors {
|
||||||
types[actor.Type()] += 1
|
typ := actor.Type()
|
||||||
|
if named, ok := actor.(Named); ok {
|
||||||
|
typ = fmt.Sprintf("%s/%s", typ, named.Name())
|
||||||
|
}
|
||||||
|
types[typ] += 1
|
||||||
}
|
}
|
||||||
for typ, count := range types {
|
for typ, count := range types {
|
||||||
if count > 1 {
|
if count > 1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user