2023-07-19 13:56:43 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/thegeeklab/url-parser/config"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// User prints out the user part from url.
|
2023-07-19 18:39:30 +00:00
|
|
|
func User(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
|
|
|
|
2024-11-05 13:35:26 +00:00
|
|
|
if parts.Username != "" {
|
|
|
|
fmt.Println(parts.Username)
|
2023-07-19 13:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|