Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update warg, auto-ignore READMEs, closes #7 #9

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

All notable changes to this project will be documented in this file. The format
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## v0.0.19 (Unreleased)


## Changed

- `--ignore` flag now ignores `README.*` by default. Pass `-i UNSET` to not ignore anything.

17 changes: 12 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
module go.bbkane.com/fling

go 1.18
go 1.21

toolchain go1.21.4

require (
github.com/karrick/godirwalk v1.16.1
go.bbkane.com/gocolor v0.0.4
go.bbkane.com/warg v0.0.15
github.com/stretchr/testify v1.8.0
go.bbkane.com/gocolor v0.0.5
go.bbkane.com/warg v0.0.21
)

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

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

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

color, err := help.ConditionallyEnableColor(ctx.Flags, os.Stdout)
color, err := common.ConditionallyEnableColor(ctx.Flags, os.Stdout)
if err != nil {
fmt.Fprintf(os.Stderr, "Error enabling color. Continuing without: %v\n", err)
}
Expand Down
44 changes: 20 additions & 24 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,44 +1,50 @@
package main

import (
"os"

"go.bbkane.com/warg"
"go.bbkane.com/warg/command"
"go.bbkane.com/warg/flag"
"go.bbkane.com/warg/section"
"go.bbkane.com/warg/value"
"go.bbkane.com/warg/value/scalar"
"go.bbkane.com/warg/value/slice"
)

func app() *warg.App {
linkUnlinkFlags := flag.FlagMap{
"--ask": flag.New(
"Whether to ask before making changes",
value.StringEnum("true", "false", "dry-run"),
flag.Default("true"),
scalar.String(
scalar.Choices("true", "false", "dry-run"),
scalar.Default("true"),
),
flag.Required(),
),
"--dotfiles": flag.New(
"Files/dirs starting with 'dot-' will have links starting with '.'",
value.Bool,
flag.Default("true"),
scalar.Bool(
scalar.Default(true),
),
flag.Required(),
),
"--ignore": flag.New(
"Ignore file/dir if the name (not the whole path) matches passed regex",
value.StringSlice,
slice.String(
slice.Default([]string{"README.*"}),
),
flag.Alias("-i"),
flag.UnsetSentinel("UNSET"),
),
"--link-dir": flag.New(
"Symlinks will be created in this directory pointing to files/directories in --src-dir",
value.Path,
scalar.Path(
scalar.Default("~"),
),
flag.Alias("-l"),
flag.Default("~"),
flag.Required(),
),
"--src-dir": flag.New(
"Directory containing files and directories to link to",
value.Path,
scalar.Path(),
flag.Alias("-s"),
flag.Required(),
),
Expand All @@ -48,11 +54,6 @@ func app() *warg.App {
"fling",
section.New(
"Link and unlink directory heirarchies ",
section.Command(
"version",
"Print version",
printVersion,
),
section.Command(
"link",
"Create links",
Expand All @@ -65,13 +66,8 @@ func app() *warg.App {
unlink,
command.ExistingFlags(linkUnlinkFlags),
),
section.Flag(
"--color",
"Control color (including for --help)",
value.StringEnum("true", "false", "auto"),
flag.Alias("-c"),
flag.Default("auto"),
),
section.ExistingCommand("version", warg.VersionCommand()),
section.ExistingFlag("--color", warg.ColorFlag()),
section.Footer("Homepage: https://github.com/bbkane/fling"),
),
warg.SkipValidation(),
Expand All @@ -80,5 +76,5 @@ func app() *warg.App {
}

func main() {
app().MustRun(os.Args, os.LookupEnv)
app().MustRun()
}
6 changes: 3 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package main

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestBuildApp(t *testing.T) {
if err := app().Validate(); err != nil {
t.Fatal(err)
}
require.Nil(t, app().Validate())
}
29 changes: 0 additions & 29 deletions version.go

This file was deleted.