Add the initial rough skeleton for a config tool.
This commit is contained in:
parent
8d2b15a7c8
commit
1ac689cd04
3 changed files with 49 additions and 1 deletions
|
@ -50,7 +50,7 @@ func getConfigFilePaths(directory string) ([]string, error) {
|
|||
if err != nil {
|
||||
return nil, errors.New("failed to create config directory at " + directory)
|
||||
} else {
|
||||
return nil, errors.New("no config files found at " + directory)
|
||||
return nil, &EmptyConfigError{directory}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,5 +63,9 @@ func getConfigFilePaths(directory string) ([]string, error) {
|
|||
paths = append(paths, filepath.Join(directory, file.Name()))
|
||||
}
|
||||
|
||||
if len(paths) == 0 {
|
||||
return nil, &EmptyConfigError{directory}
|
||||
}
|
||||
|
||||
return paths, nil
|
||||
}
|
||||
|
|
11
internal/configparser/errors.go
Normal file
11
internal/configparser/errors.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package configparser
|
||||
|
||||
import "fmt"
|
||||
|
||||
type EmptyConfigError struct {
|
||||
directory string
|
||||
}
|
||||
|
||||
func (e *EmptyConfigError) Error() string {
|
||||
return fmt.Sprintf("no config files found at %s", e.directory)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue