feat: implement update command and add error check for toml key access

This commit is contained in:
2025-09-25 23:52:13 +05:30
parent 54c23bad6f
commit ed9201851e
6 changed files with 91 additions and 11 deletions

View File

@@ -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 {