diff --git a/config.go b/config.go index f3ad461..63b2a72 100644 --- a/config.go +++ b/config.go @@ -10,6 +10,7 @@ import ( "go.bbkane.com/logos" "go.bbkane.com/warg/command" "go.bbkane.com/warg/help/common" + "go.bbkane.com/warg/path" "go.uber.org/zap" lumberjack "gopkg.in/natefinch/lumberjack.v2" ) @@ -20,7 +21,7 @@ var embeddedConfig []byte func editConfig(ctx command.Context) error { // retrieve types: lumberJackLogger := &lumberjack.Logger{ - Filename: ctx.Flags["--log-filename"].(string), + Filename: ctx.Flags["--log-filename"].(path.Path).MustExpand(), MaxAge: ctx.Flags["--log-maxage"].(int), MaxBackups: ctx.Flags["--log-maxbackups"].(int), MaxSize: ctx.Flags["--log-maxsize"].(int), @@ -37,7 +38,7 @@ func editConfig(ctx command.Context) error { logger := logos.New(zapLogger, color) logger.LogOnPanic() - configPath, configPathExists := ctx.Flags["--config"].(string) + configPath, configPathExists := ctx.Flags["--config"] if !configPathExists { err := errors.New("must path --config") logger.Errorw( @@ -48,7 +49,7 @@ func editConfig(ctx command.Context) error { } editor := ctx.Flags["--editor"].(string) - err = glib.EditFile(embeddedConfig, configPath, editor) + err = glib.EditFile(embeddedConfig, configPath.(path.Path).MustExpand(), editor) if err != nil { logger.Errorw( "Unable to edit config", diff --git a/go.mod b/go.mod index 44add23..48b27bd 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,13 @@ module go.bbkane.com/grabbit/v4 -go 1.22 +go 1.23 require ( github.com/bbkane/glib v0.1.1 github.com/pkg/errors v0.9.1 github.com/vartanbeno/go-reddit/v2 v2.0.1 go.bbkane.com/logos v0.4.0 - go.bbkane.com/warg v0.0.23 + go.bbkane.com/warg v0.0.26 go.uber.org/zap v1.27.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) @@ -28,6 +28,6 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.26.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/sys v0.29.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index b06b678..28c671b 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,8 @@ go.bbkane.com/logos v0.4.0 h1:7k6mQiSK7ZXJa/OGZATxCeNgZX9D0qPx+NwWwEb2NwA= go.bbkane.com/logos v0.4.0/go.mod h1:sxAz5z3jxSA3GQ2z6NL7wmGXISGQKCuA7XM0DGY+fKE= go.bbkane.com/warg v0.0.23 h1:Eh0sEXkl+GudyPLHLJGzAOAhzFnnzxanxLXi1hrOKhU= go.bbkane.com/warg v0.0.23/go.mod h1:fuaPJpxxTab3Yf8GFI3c0O6ou09UE7tdcXY0XTB2hRc= +go.bbkane.com/warg v0.0.26 h1:jaNPwisZLuD9Ga3yWKPLWFmsBt1lh9eLoSkJEXqgtHU= +go.bbkane.com/warg v0.0.26/go.mod h1:xttS0YH1LCuFurEvk2mu2jn9DCKYS8T8sokxNg2JARo= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -54,6 +56,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/grab.go b/grab.go index 8ad9e52..5607e4d 100644 --- a/grab.go +++ b/grab.go @@ -20,6 +20,7 @@ import ( "go.bbkane.com/logos" "go.bbkane.com/warg/command" "go.bbkane.com/warg/help/common" + "go.bbkane.com/warg/path" "go.uber.org/zap" lumberjack "gopkg.in/natefinch/lumberjack.v2" ) @@ -293,16 +294,22 @@ func testRedditConnection(logger *logos.Logger) error { // Test connection conn, err := tls.DialWithDialer( &net.Dialer{ - Timeout: time.Second * 30, + Cancel: nil, + Control: nil, + ControlContext: nil, Deadline: time.Time{}, - LocalAddr: nil, DualStack: false, FallbackDelay: 0, KeepAlive: 0, - Resolver: nil, - Cancel: nil, - Control: nil, - ControlContext: nil, + KeepAliveConfig: net.KeepAliveConfig{ + Enable: false, + Idle: 0, + Interval: 0, + Count: 0, + }, + LocalAddr: nil, + Resolver: nil, + Timeout: time.Second * 30, }, "tcp", net.JoinHostPort("reddit.com", "443"), @@ -336,7 +343,7 @@ func grab(ctx command.Context) error { // retrieve types: lumberJackLogger := &lumberjack.Logger{ - Filename: ctx.Flags["--log-filename"].(string), + Filename: ctx.Flags["--log-filename"].(path.Path).MustExpand(), MaxAge: ctx.Flags["--log-maxage"].(int), MaxBackups: ctx.Flags["--log-maxbackups"].(int), MaxSize: ctx.Flags["--log-maxsize"].(int), @@ -353,7 +360,7 @@ func grab(ctx command.Context) error { logger := logos.New(zapLogger, color) logger.LogOnPanic() - subredditDestinations := ctx.Flags["--subreddit-destination"].([]string) + subredditDestinations := ctx.Flags["--subreddit-destination"].([]path.Path) subredditLimits := ctx.Flags["--subreddit-limit"].([]int) subredditNames := ctx.Flags["--subreddit-name"].([]string) subredditTimeframes := ctx.Flags["--subreddit-timeframe"].([]string) @@ -382,7 +389,7 @@ func grab(ctx command.Context) error { sr := subreddit{ Name: subredditNames[i], - Destination: subredditDestinations[i], + Destination: subredditDestinations[i].MustExpand(), Timeframe: subredditTimeframes[i], Limit: subredditLimits[i], } diff --git a/main.go b/main.go index 4b08e26..3a00e61 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "go.bbkane.com/warg/command" "go.bbkane.com/warg/config/yamlreader" "go.bbkane.com/warg/flag" + "go.bbkane.com/warg/path" "go.bbkane.com/warg/section" "go.bbkane.com/warg/value/scalar" "go.bbkane.com/warg/value/slice" @@ -35,7 +36,7 @@ Homepage: https://github.com/bbkane/grabbit "--log-filename": flag.New( "Log filename", scalar.Path( - scalar.Default("~/.config/grabbit.jsonl"), + scalar.Default(path.New("~/.config/grabbit.jsonl")), ), flag.ConfigPath("lumberjacklogger.filename"), flag.Required(), @@ -89,7 +90,7 @@ Homepage: https://github.com/bbkane/grabbit "--subreddit-destination", "Where to store the subreddit", slice.Path( - slice.Default([]string{".", "."}), + slice.Default([]path.Path{path.New("."), path.New(".")}), ), flag.Alias("-sd"), flag.ConfigPath("subreddits[].destination"), @@ -152,8 +153,8 @@ Homepage: https://github.com/bbkane/grabbit ), warg.ConfigFlag( "--config", - []scalar.ScalarOpt[string]{ - scalar.Default("~/.config/grabbit.yaml"), + []scalar.ScalarOpt[path.Path]{ + scalar.Default(path.New("~/.config/grabbit.yaml")), }, yamlreader.New, "Config filepath",