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.
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)

View File

@ -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())

View File

@ -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()

View File

@ -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 {

View File

@ -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())

View File

@ -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 != "" {

View File

@ -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)

View File

@ -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)

View File

@ -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 {