rename config object

This commit is contained in:
Robert Kaussow 2023-07-19 16:55:15 +02:00
parent 1ced50a387
commit ef357c4828
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
9 changed files with 24 additions and 24 deletions

View File

@ -8,9 +8,9 @@ import (
) )
// Fragment prints out the fragment part from the url. // 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 { return func(ctx *cli.Context) error {
parts := parseURL(config.URL) parts := parseURL(cfg.URL)
if len(parts.Scheme) > 0 { if len(parts.Scheme) > 0 {
fmt.Println(parts.Fragment) fmt.Println(parts.Fragment)

View File

@ -8,9 +8,9 @@ import (
) )
// Host prints out the host part from the url. // 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 { return func(ctx *cli.Context) error {
parts := parseURL(config.URL) parts := parseURL(cfg.URL)
if len(parts.Scheme) > 0 { if len(parts.Scheme) > 0 {
fmt.Println(parts.Hostname()) fmt.Println(parts.Hostname())

View File

@ -8,9 +8,9 @@ import (
) )
// Password prints out the password part from url. // 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 { return func(ctx *cli.Context) error {
parts := parseURL(config.URL) parts := parseURL(cfg.URL)
if parts.User != nil { if parts.User != nil {
pw, _ := parts.User.Password() pw, _ := parts.User.Password()

View File

@ -9,23 +9,23 @@ import (
) )
// PathFlags defines flags for path subcommand. // PathFlags defines flags for path subcommand.
func PathFlags(config *config.Config) []cli.Flag { func PathFlags(cfg *config.Config) []cli.Flag {
return []cli.Flag{ return []cli.Flag{
&cli.IntFlag{ &cli.IntFlag{
Name: "path-index", Name: "path-index",
Usage: "filter parsed path by index", Usage: "filter parsed path by index",
EnvVars: []string{"URL_PARSER_PATH_INDEX"}, EnvVars: []string{"URL_PARSER_PATH_INDEX"},
Value: -1, Value: -1,
Destination: &config.PathIndex, Destination: &cfg.PathIndex,
}, },
} }
} }
// Path prints out the path part from url. // 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 { return func(ctx *cli.Context) error {
parts := parseURL(config.URL) parts := parseURL(cfg.URL)
i := config.PathIndex i := cfg.PathIndex
if len(parts.Path) > 0 { if len(parts.Path) > 0 {
if i > -1 { if i > -1 {

View File

@ -8,9 +8,9 @@ import (
) )
// Port prints out the port from the url. // 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 { return func(ctx *cli.Context) error {
parts := parseURL(config.URL) parts := parseURL(cfg.URL)
if len(parts.Scheme) > 0 { if len(parts.Scheme) > 0 {
fmt.Println(parts.Port()) fmt.Println(parts.Port())

View File

@ -8,22 +8,22 @@ import (
) )
// QueryFlags defines flags for query subcommand. // QueryFlags defines flags for query subcommand.
func QueryFlags(config *config.Config) []cli.Flag { func QueryFlags(cfg *config.Config) []cli.Flag {
return []cli.Flag{ return []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "query-field", Name: "query-field",
Usage: "filter parsed query string by field name", Usage: "filter parsed query string by field name",
EnvVars: []string{"URL_PARSER_QUERY_FIELD"}, EnvVars: []string{"URL_PARSER_QUERY_FIELD"},
Destination: &config.QueryField, Destination: &cfg.QueryField,
}, },
} }
} }
// Query prints out the query part from url. // 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 { return func(ctx *cli.Context) error {
parts := parseURL(config.URL) parts := parseURL(cfg.URL)
f := config.QueryField f := cfg.QueryField
if len(parts.RawQuery) > 0 { if len(parts.RawQuery) > 0 {
if f != "" { if f != "" {

View File

@ -8,9 +8,9 @@ import (
) )
// Run default command and print out full url. // 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 { return func(ctx *cli.Context) error {
parts := parseURL(config.URL) parts := parseURL(cfg.URL)
if len(parts.String()) > 0 { if len(parts.String()) > 0 {
fmt.Println(parts) fmt.Println(parts)

View File

@ -8,9 +8,9 @@ import (
) )
// Scheme prints out the scheme part from the url. // 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 { return func(ctx *cli.Context) error {
parts := parseURL(config.URL) parts := parseURL(cfg.URL)
if len(parts.Scheme) > 0 { if len(parts.Scheme) > 0 {
fmt.Println(parts.Scheme) fmt.Println(parts.Scheme)

View File

@ -8,9 +8,9 @@ import (
) )
// User prints out the user part from url. // 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 { return func(ctx *cli.Context) error {
parts := parseURL(config.URL) parts := parseURL(cfg.URL)
if parts.User != nil { if parts.User != nil {
if len(parts.User.Username()) > 0 { if len(parts.User.Username()) > 0 {