Skip to content

Commit 078940b

Browse files
authored
Merge pull request #9 from bbkane/bbkane/issue7
Update warg, auto-ignore READMEs, closes #7
2 parents 2a4ce35 + 3fc1c23 commit 078940b

File tree

7 files changed

+81
-77
lines changed

7 files changed

+81
-77
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file. The format
4+
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
5+
6+
## v0.0.19 (Unreleased)
7+
8+
9+
## Changed
10+
11+
- `--ignore` flag now ignores `README.*` by default. Pass `-i UNSET` to not ignore anything.
12+

go.mod

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
module go.bbkane.com/fling
22

3-
go 1.18
3+
go 1.21
4+
5+
toolchain go1.21.4
46

57
require (
68
github.com/karrick/godirwalk v1.16.1
7-
go.bbkane.com/gocolor v0.0.4
8-
go.bbkane.com/warg v0.0.15
9+
github.com/stretchr/testify v1.8.0
10+
go.bbkane.com/gocolor v0.0.5
11+
go.bbkane.com/warg v0.0.21
912
)
1013

1114
require (
12-
github.com/mattn/go-isatty v0.0.14 // indirect
15+
github.com/davecgh/go-spew v1.1.1 // indirect
16+
github.com/kr/text v0.2.0 // indirect
17+
github.com/mattn/go-isatty v0.0.16 // indirect
1318
github.com/mitchellh/go-homedir v1.1.0 // indirect
19+
github.com/pmezard/go-difflib v1.0.0 // indirect
1420
github.com/xhit/go-str2duration/v2 v2.0.0 // indirect
15-
golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68 // indirect
21+
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
22+
gopkg.in/yaml.v3 v3.0.1 // indirect
1623
)

go.sum

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
1-
github.com/alecthomas/assert v1.0.0 h1:3XmGh/PSuLzDbK3W2gUbRXwgW5lqPkuqvRgeQ30FI5o=
2-
github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk=
3-
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae h1:zzGwJfFlFGD94CyyYwCJeSuD32Gj9GTaSi5y9hoVzdY=
1+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
45
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
56
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
6-
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
7-
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
7+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
8+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
9+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
10+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
11+
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
12+
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
813
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
914
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
10-
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
15+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
16+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
17+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
18+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
19+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
20+
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
21+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
1122
github.com/xhit/go-str2duration/v2 v2.0.0 h1:uFtk6FWB375bP7ewQl+/1wBcn840GPhnySOdcz/okPE=
1223
github.com/xhit/go-str2duration/v2 v2.0.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
13-
go.bbkane.com/gocolor v0.0.4 h1:UI4ejgjHdC6oupH8src8+FQgbbfcZ6C7BSPZzecBjzs=
14-
go.bbkane.com/gocolor v0.0.4/go.mod h1:7AEOm8kyPlpj9qr/SL9mEXSceh8xM2w+eBm4deMRNHk=
15-
go.bbkane.com/warg v0.0.15 h1:rRD9x4yoent7Ngq9eUiK28TeQbonx6k9MYH/ZJWQFJA=
16-
go.bbkane.com/warg v0.0.15/go.mod h1:QaSFzxmNkz6krxg8yKnCp4yAQPH6GuIWGQCVU0e6ByU=
17-
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
18-
golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68 h1:z8Hj/bl9cOV2grsOpEaQFUaly0JWN3i97mo3jXKJNp0=
19-
golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
24+
go.bbkane.com/gocolor v0.0.5 h1:WrdijR+XIH9QXXYUYTPH7m8QGIp7wLdMFWKL+8bK38Q=
25+
go.bbkane.com/gocolor v0.0.5/go.mod h1:7AEOm8kyPlpj9qr/SL9mEXSceh8xM2w+eBm4deMRNHk=
26+
go.bbkane.com/warg v0.0.21 h1:3BQxINoa8U7g2tlbSwopGUqqM7SC8aUAhpn5BzsTiLs=
27+
go.bbkane.com/warg v0.0.21/go.mod h1:LTSM3kaBWKU29DPYIjJkhIQ1oKQ1egdDgZ+Ae8uSB4A=
28+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
29+
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
30+
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
31+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
32+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
33+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2034
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
35+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
36+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
37+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
38+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

link_unlink.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/karrick/godirwalk"
1414
"go.bbkane.com/gocolor"
1515
"go.bbkane.com/warg/command"
16-
"go.bbkane.com/warg/help"
16+
"go.bbkane.com/warg/help/common"
1717
)
1818

1919
// checkMode for types of files we're not prepared to deal with :)
@@ -414,7 +414,7 @@ func unlink(ctx command.Context) error {
414414
ignorePatterns = ignoreF.([]string)
415415
}
416416

417-
color, err := help.ConditionallyEnableColor(ctx.Flags, os.Stdout)
417+
color, err := common.ConditionallyEnableColor(ctx.Flags, os.Stdout)
418418
if err != nil {
419419
fmt.Fprintf(os.Stderr, "Error enabling color. Continuing without: %v\n", err)
420420
}
@@ -537,7 +537,7 @@ func link(ctx command.Context) error {
537537
ignorePatterns = ignoreF.([]string)
538538
}
539539

540-
color, err := help.ConditionallyEnableColor(ctx.Flags, os.Stdout)
540+
color, err := common.ConditionallyEnableColor(ctx.Flags, os.Stdout)
541541
if err != nil {
542542
fmt.Fprintf(os.Stderr, "Error enabling color. Continuing without: %v\n", err)
543543
}

main.go

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,50 @@
11
package main
22

33
import (
4-
"os"
5-
64
"go.bbkane.com/warg"
75
"go.bbkane.com/warg/command"
86
"go.bbkane.com/warg/flag"
97
"go.bbkane.com/warg/section"
10-
"go.bbkane.com/warg/value"
8+
"go.bbkane.com/warg/value/scalar"
9+
"go.bbkane.com/warg/value/slice"
1110
)
1211

1312
func app() *warg.App {
1413
linkUnlinkFlags := flag.FlagMap{
1514
"--ask": flag.New(
1615
"Whether to ask before making changes",
17-
value.StringEnum("true", "false", "dry-run"),
18-
flag.Default("true"),
16+
scalar.String(
17+
scalar.Choices("true", "false", "dry-run"),
18+
scalar.Default("true"),
19+
),
1920
flag.Required(),
2021
),
2122
"--dotfiles": flag.New(
2223
"Files/dirs starting with 'dot-' will have links starting with '.'",
23-
value.Bool,
24-
flag.Default("true"),
24+
scalar.Bool(
25+
scalar.Default(true),
26+
),
2527
flag.Required(),
2628
),
2729
"--ignore": flag.New(
2830
"Ignore file/dir if the name (not the whole path) matches passed regex",
29-
value.StringSlice,
31+
slice.String(
32+
slice.Default([]string{"README.*"}),
33+
),
3034
flag.Alias("-i"),
35+
flag.UnsetSentinel("UNSET"),
3136
),
3237
"--link-dir": flag.New(
3338
"Symlinks will be created in this directory pointing to files/directories in --src-dir",
34-
value.Path,
39+
scalar.Path(
40+
scalar.Default("~"),
41+
),
3542
flag.Alias("-l"),
36-
flag.Default("~"),
3743
flag.Required(),
3844
),
3945
"--src-dir": flag.New(
4046
"Directory containing files and directories to link to",
41-
value.Path,
47+
scalar.Path(),
4248
flag.Alias("-s"),
4349
flag.Required(),
4450
),
@@ -48,11 +54,6 @@ func app() *warg.App {
4854
"fling",
4955
section.New(
5056
"Link and unlink directory heirarchies ",
51-
section.Command(
52-
"version",
53-
"Print version",
54-
printVersion,
55-
),
5657
section.Command(
5758
"link",
5859
"Create links",
@@ -65,13 +66,8 @@ func app() *warg.App {
6566
unlink,
6667
command.ExistingFlags(linkUnlinkFlags),
6768
),
68-
section.Flag(
69-
"--color",
70-
"Control color (including for --help)",
71-
value.StringEnum("true", "false", "auto"),
72-
flag.Alias("-c"),
73-
flag.Default("auto"),
74-
),
69+
section.ExistingCommand("version", warg.VersionCommand()),
70+
section.ExistingFlag("--color", warg.ColorFlag()),
7571
section.Footer("Homepage: https://github.com/bbkane/fling"),
7672
),
7773
warg.SkipValidation(),
@@ -80,5 +76,5 @@ func app() *warg.App {
8076
}
8177

8278
func main() {
83-
app().MustRun(os.Args, os.LookupEnv)
79+
app().MustRun()
8480
}

main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package main
22

33
import (
44
"testing"
5+
6+
"github.com/stretchr/testify/require"
57
)
68

79
func TestBuildApp(t *testing.T) {
8-
if err := app().Validate(); err != nil {
9-
t.Fatal(err)
10-
}
10+
require.Nil(t, app().Validate())
1111
}

version.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)