feat(envc): add support for converting current process environment to YAML

Enhance the `envc convert` command to allow conversion of the current process environment to YAML format. Update README with usage examples and clarify input options. Add tests to ensure correct functionality for environment variable handling.
This commit is contained in:
2026-05-12 12:27:46 +01:00
parent 474cd88739
commit b7709d693b
4 changed files with 105 additions and 12 deletions
+27
View File
@@ -8,6 +8,33 @@ import (
"testing"
)
func TestRunConvert_EnvironToYAML(t *testing.T) {
t.Setenv("ENVC_TEST_PUBLISH", "xyzzy")
var stdout, stderr bytes.Buffer
code := RunConvert([]string{
"--from", "env", "--to", "yaml",
"--input", "environ", "--output", "-",
}, strings.NewReader(""), &stdout, &stderr)
if code != 0 {
t.Fatalf("stderr: %s", stderr.String())
}
out := stdout.String()
if !strings.Contains(out, "xyzzy") {
t.Fatalf("expected value in yaml out: %s", out)
}
}
func TestRuknConvert_EnvironRequiresFromEnv(t *testing.T) {
var stdout, stderr bytes.Buffer
code := RunConvert([]string{
"--from", "yaml", "--to", "json",
"--input", "environ", "--output", "-",
}, strings.NewReader(""), &stdout, &stderr)
if code != 2 {
t.Fatalf("expected exit 2, got %d stderr=%s", code, stderr.String())
}
}
func TestRunConvert_TOMLToJSON(t *testing.T) {
var stdout, stderr bytes.Buffer
stdin := strings.NewReader("[app]\nport = 8080\n")