cfg @main -
refs -
log -
-
https://git.jolheiser.com/cfg.git
Signature
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmZiZy0ACgkQuFOtpdp7
v3pC+g//elROutwDHzfm+fQRqOp+WHGKEFZ2e047fiDB+YxkptRzgcfV7X5jz0HU
UguGhT3P8om4QDimPbW3O/WZc9iYqfPf3sfJEeOeL3E8CuzDjlkF6NLeP6E530at
lVshqpRbVRDHv8dHxkp/8voRgzyhG4L+5yTHV6OPFSe2vXjg2nYCZYrVyoEtQ88R
vXIJqqlObRF/QI2dND5ZUkccS1HU8+wxt13pvR5XSERZx/4wbPFBdw2ZKVpOyB45
d9YBKFbTMMW6hcZ6HnZMHcruOc2Elm4yjKUfp7lULx75jh4w7cKeB99ACSd8J6KM
yPmgvfYBf8m3xfE0+01HtuyeGXJmK4rYu5JrHrycnTOtPPWFCXJOyXy5HKv0L6wV
i9NMs8bMIIFC8p2Ll0UW+Cn+T3VmbxP+nJNqcF929B1NLDlDBpue+t2AVtgPrnrt
7it3xqKtwBp5Ym9NhrAq4oWvKwJ1qjWWEV8lDGjX2hQUggu+plIjn4etAkOEy31d
LsvrqjLFaNXfnSlUpWsgdQSmzbmOQw+4nSC+N6tI437vb75ttHNllpOsN8W/0+Rc
XqLDcJkfBhgTkjvBjDWXdJsQRDhhydSKx722g4bJiWqZEftr7UvyX9UFfWJ56uYd
1xzE57NqCL9gV5AxvJq7PX1cC4sHDAWQShh/UhO+bSDxLWewo1g=
=ktM4
-----END PGP SIGNATURE-----
diff --git a/cmd/cfg/main.go b/cmd/cfg/main.go
index 71625957efd9690d9ff4f81139406b09a15068fa..ccb142eef5410054bc4359e8af877717d7376604 100644
--- a/cmd/cfg/main.go
+++ b/cmd/cfg/main.go
@@ -24,7 +24,7 @@ }
unmarshal = e.Unmarshal
return nil
}
- fs.Func("from", "The format to convert from", fromFunc)
+ fs.Func("from", "The format to convert from [json(c), yaml, toml, nix, dhall]", fromFunc)
fs.Func("f", "--from", fromFunc)
toFunc := func(s string) error {
e, err := cfg.ParseEncoding(s)
@@ -34,7 +34,7 @@ }
marshal = e.Marshal
return nil
}
- fs.Func("to", "The format to convert to", toFunc)
+ fs.Func("to", "The format to convert to [json, yaml, toml, nix]", toFunc)
fs.Func("t", "--to", toFunc)
if err := fs.Parse(os.Args[1:]); err != nil {
return err
@@ -44,10 +44,14 @@ if fs.NArg() < 1 {
return errors.New("cfg requires at least an input file")
}
+ cleanArg := func(arg string) string {
+ return strings.TrimPrefix(filepath.Ext(arg), ".")
+ }
+
in := fs.Arg(0)
if unmarshal == nil {
-import (
"fmt"
+ "errors"
return err
}
}
@@ -62,7 +66,7 @@ defer fi.Close()
out = fi
if marshal == nil {
- if err := toFunc(strings.TrimPrefix(filepath.Ext(fs.Arg(1)), ".")); err != nil {
+ if err := toFunc(cleanArg(fs.Arg(1))); err != nil {
return err
}
}