Add more CLI commands
This commit is contained in:
parent
475d424f32
commit
8ceafff09b
21 changed files with 995 additions and 107 deletions
|
|
@ -35,6 +35,14 @@ func LoadConfig() (*Config, error) {
|
|||
return nil, errors.Wrap(err, "fetching config")
|
||||
}
|
||||
|
||||
if _, err := os.Stat(cfgFile); err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
// return empty config
|
||||
return &Config{}, nil
|
||||
}
|
||||
return nil, errors.Wrap(err, "accessing config file")
|
||||
}
|
||||
|
||||
var config Config
|
||||
if _, err := toml.DecodeFile(cfgFile, &config); err != nil {
|
||||
return nil, errors.Wrap(err, "decoding toml")
|
||||
|
|
|
|||
|
|
@ -4,16 +4,17 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func getHomeDir() (string, error) {
|
||||
home := os.Getenv("HOME")
|
||||
home, err := os.UserHomeDir()
|
||||
|
||||
if home == "" {
|
||||
return "", fmt.Errorf("failed to get home folder")
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "fetching home dir")
|
||||
}
|
||||
|
||||
return filepath.Join(home, ".local", "share", DefaultAppFolder), nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue