From ef357c4828512e5724f03dc9a996830b9839ffc9 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 19 Jul 2023 16:55:15 +0200 Subject: [PATCH] rename config object --- command/fragment.go | 4 ++-- command/host.go | 4 ++-- command/password.go | 4 ++-- command/path.go | 10 +++++----- command/port.go | 4 ++-- command/query.go | 10 +++++----- command/run.go | 4 ++-- command/scheme.go | 4 ++-- command/user.go | 4 ++-- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/command/fragment.go b/command/fragment.go index 49720fb..dcf34ba 100644 --- a/command/fragment.go +++ b/command/fragment.go @@ -8,9 +8,9 @@ import ( ) // Fragment prints out the fragment part from the url. -func Fragment(config *config.Config) cli.ActionFunc { +func Fragment(cfg *config.Config) cli.ActionFunc { return func(ctx *cli.Context) error { - parts := parseURL(config.URL) + parts := parseURL(cfg.URL) if len(parts.Scheme) > 0 { fmt.Println(parts.Fragment) diff --git a/command/host.go b/command/host.go index 9950c4e..03e20f1 100644 --- a/command/host.go +++ b/command/host.go @@ -8,9 +8,9 @@ import ( ) // Host prints out the host part from the url. -func Host(config *config.Config) cli.ActionFunc { +func Host(cfg *config.Config) cli.ActionFunc { return func(ctx *cli.Context) error { - parts := parseURL(config.URL) + parts := parseURL(cfg.URL) if len(parts.Scheme) > 0 { fmt.Println(parts.Hostname()) diff --git a/command/password.go b/command/password.go index 5c03ed3..5e75b3b 100644 --- a/command/password.go +++ b/command/password.go @@ -8,9 +8,9 @@ import ( ) // Password prints out the password part from url. -func Password(config *config.Config) cli.ActionFunc { +func Password(cfg *config.Config) cli.ActionFunc { return func(ctx *cli.Context) error { - parts := parseURL(config.URL) + parts := parseURL(cfg.URL) if parts.User != nil { pw, _ := parts.User.Password() diff --git a/command/path.go b/command/path.go index 2ffa421..499c08d 100644 --- a/command/path.go +++ b/command/path.go @@ -9,23 +9,23 @@ import ( ) // PathFlags defines flags for path subcommand. -func PathFlags(config *config.Config) []cli.Flag { +func PathFlags(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.IntFlag{ Name: "path-index", Usage: "filter parsed path by index", EnvVars: []string{"URL_PARSER_PATH_INDEX"}, Value: -1, - Destination: &config.PathIndex, + Destination: &cfg.PathIndex, }, } } // Path prints out the path part from url. -func Path(config *config.Config) cli.ActionFunc { +func Path(cfg *config.Config) cli.ActionFunc { return func(ctx *cli.Context) error { - parts := parseURL(config.URL) - i := config.PathIndex + parts := parseURL(cfg.URL) + i := cfg.PathIndex if len(parts.Path) > 0 { if i > -1 { diff --git a/command/port.go b/command/port.go index 5f76d6a..4bd71e6 100644 --- a/command/port.go +++ b/command/port.go @@ -8,9 +8,9 @@ import ( ) // Port prints out the port from the url. -func Port(config *config.Config) cli.ActionFunc { +func Port(cfg *config.Config) cli.ActionFunc { return func(ctx *cli.Context) error { - parts := parseURL(config.URL) + parts := parseURL(cfg.URL) if len(parts.Scheme) > 0 { fmt.Println(parts.Port()) diff --git a/command/query.go b/command/query.go index ab1db68..aa26766 100644 --- a/command/query.go +++ b/command/query.go @@ -8,22 +8,22 @@ import ( ) // QueryFlags defines flags for query subcommand. -func QueryFlags(config *config.Config) []cli.Flag { +func QueryFlags(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "query-field", Usage: "filter parsed query string by field name", EnvVars: []string{"URL_PARSER_QUERY_FIELD"}, - Destination: &config.QueryField, + Destination: &cfg.QueryField, }, } } // Query prints out the query part from url. -func Query(config *config.Config) cli.ActionFunc { +func Query(cfg *config.Config) cli.ActionFunc { return func(ctx *cli.Context) error { - parts := parseURL(config.URL) - f := config.QueryField + parts := parseURL(cfg.URL) + f := cfg.QueryField if len(parts.RawQuery) > 0 { if f != "" { diff --git a/command/run.go b/command/run.go index 75d3438..440b937 100644 --- a/command/run.go +++ b/command/run.go @@ -8,9 +8,9 @@ import ( ) // Run default command and print out full url. -func Run(config *config.Config) cli.ActionFunc { +func Run(cfg *config.Config) cli.ActionFunc { return func(ctx *cli.Context) error { - parts := parseURL(config.URL) + parts := parseURL(cfg.URL) if len(parts.String()) > 0 { fmt.Println(parts) diff --git a/command/scheme.go b/command/scheme.go index 7f4451f..f63ad25 100644 --- a/command/scheme.go +++ b/command/scheme.go @@ -8,9 +8,9 @@ import ( ) // Scheme prints out the scheme part from the url. -func Scheme(config *config.Config) cli.ActionFunc { +func Scheme(cfg *config.Config) cli.ActionFunc { return func(ctx *cli.Context) error { - parts := parseURL(config.URL) + parts := parseURL(cfg.URL) if len(parts.Scheme) > 0 { fmt.Println(parts.Scheme) diff --git a/command/user.go b/command/user.go index b564a9a..44022e1 100644 --- a/command/user.go +++ b/command/user.go @@ -8,9 +8,9 @@ import ( ) // User prints out the user part from url. -func User(config *config.Config) cli.ActionFunc { +func User(cfg *config.Config) cli.ActionFunc { return func(ctx *cli.Context) error { - parts := parseURL(config.URL) + parts := parseURL(cfg.URL) if parts.User != nil { if len(parts.User.Username()) > 0 {