mirror of
https://github.com/silicoflare/envy.git
synced 2026-05-26 19:57:59 +05:30
feat: implement update command and add error check for toml key access
This commit is contained in:
@@ -44,6 +44,18 @@ func GetEnvy() (*toml.Tree, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetKey(t *toml.Tree, key string) (string, error) {
|
||||
v := t.Get(key)
|
||||
if v == nil {
|
||||
return "", fmt.Errorf("key %v not found", v)
|
||||
}
|
||||
s, ok := v.(string)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("key %q is %T, expected string", key, v)
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func WriteEnvy(tree *toml.Tree) error {
|
||||
data, err := tree.Marshal()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user