2023-07-19 13:56:43 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/thegeeklab/url-parser/config"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Host prints out the host part from the url.
|
2023-07-19 18:39:30 +00:00
|
|
|
func Host(cfg *config.Config) cli.ActionFunc {
|
2024-02-12 08:09:30 +00:00
|
|
|
return func(_ *cli.Context) error {
|
2024-11-05 13:35:26 +00:00
|
|
|
parts := NewURLParser(cfg.URL, cfg.QueryField, cfg.QuerySplit).parse()
|
2023-07-19 13:56:43 +00:00
|
|
|
|
|
|
|
if len(parts.Scheme) > 0 {
|
2024-11-05 13:35:26 +00:00
|
|
|
fmt.Println(parts.Hostname)
|
2023-07-19 13:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|