aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorXe <me@christine.website>2022-11-21 21:38:23 -0500
committerXe <me@christine.website>2022-11-21 21:38:23 -0500
commitc1fd35aa707fe8dfbd6ab1351e5e3f0564ad0b11 (patch)
treef33a52f4362b2d88226b071a07ede8a45898b55f /internal
parentbec049cf7752382b2894c9526612686bbc15ed47 (diff)
downloadx-c1fd35aa707fe8dfbd6ab1351e5e3f0564ad0b11.tar.xz
x-c1fd35aa707fe8dfbd6ab1351e5e3f0564ad0b11.zip
fix flagconfyg
Signed-off-by: Xe <me@christine.website>
Diffstat (limited to 'internal')
-rw-r--r--internal/confyg/flagconfyg/flagconfyg.go34
-rw-r--r--internal/confyg/flagconfyg/flagconfyg_test.go18
2 files changed, 0 insertions, 52 deletions
diff --git a/internal/confyg/flagconfyg/flagconfyg.go b/internal/confyg/flagconfyg/flagconfyg.go
index 823c72b..abf24a8 100644
--- a/internal/confyg/flagconfyg/flagconfyg.go
+++ b/internal/confyg/flagconfyg/flagconfyg.go
@@ -44,37 +44,3 @@ func Parse(name string, data []byte, fs *flag.FlagSet) error {
func allower(verb string, block bool) bool {
return true
}
-
-// Dump turns a flagset's values into a configuration file.
-func Dump(fs *flag.FlagSet) []byte {
- result := &confyg.FileSyntax{
- Name: fs.Name(),
- Comments: confyg.Comments{
- Before: []confyg.Comment{
- {
- Token: "// generated from " + fs.Name() + " flags",
- }, {},
- },
- },
- Stmt: []confyg.Expr{},
- }
-
- fs.Visit(func(fl *flag.Flag) {
- commentTokens := []string{"//", fl.Usage}
-
- l := &confyg.Line{
- Comments: confyg.Comments{
- Suffix: []confyg.Comment{
- {
- Token: strings.Join(commentTokens, " "),
- },
- },
- },
- Token: []string{fl.Name, fl.Value.String()},
- }
-
- result.Stmt = append(result.Stmt, l)
- })
-
- return confyg.Format(result)
-}
diff --git a/internal/confyg/flagconfyg/flagconfyg_test.go b/internal/confyg/flagconfyg/flagconfyg_test.go
index 767a699..cab7e73 100644
--- a/internal/confyg/flagconfyg/flagconfyg_test.go
+++ b/internal/confyg/flagconfyg/flagconfyg_test.go
@@ -29,21 +29,3 @@ unsubscribe (
t.Errorf("wanted unsubscribe->t-series, got: %s", *us)
}
}
-
-func TestDump(t *testing.T) {
- fs := flag.NewFlagSet("h", flag.PanicOnError)
- fs.String("test-string", "some value", "fill this in pls")
- fs.Bool("test-bool", false, "also fill this in pls")
-
- err := fs.Parse([]string{"-test-string=foo", "-test-bool"})
- if err != nil {
- t.Fatal(err)
- }
-
- data := Dump(fs)
-
- err = Parse("h.cfg", data, fs)
- if err != nil {
- t.Fatal(err)
- }
-}