@@ -91,6 +91,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if flagMatchType == "" {
|
||||
if err := huh.NewSelect[string]().
|
||||
Title("Match type").
|
||||
@@ -102,6 +103,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if flagDisplayName == "" {
|
||||
if err := huh.NewInput().Title("Display name").Value(&flagDisplayName).Run(); err != nil {
|
||||
return err
|
||||
@@ -112,9 +114,11 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
if flagPattern == "" {
|
||||
return fmt.Errorf("pattern is required; pass --pattern or run interactively")
|
||||
}
|
||||
|
||||
if flagMatchType == "" {
|
||||
return fmt.Errorf("match-type is required; pass --match-type or run interactively")
|
||||
}
|
||||
|
||||
if flagDisplayName == "" {
|
||||
return fmt.Errorf("display-name is required; pass --display-name or run interactively")
|
||||
}
|
||||
@@ -128,6 +132,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
if flagDescription != "" {
|
||||
input["description"] = flagDescription
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("max-age-seconds") {
|
||||
input["maxAgeSeconds"] = flagMaxAge
|
||||
}
|
||||
|
||||
@@ -46,10 +46,12 @@ func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
|
||||
if !f.IOStreams.IsInteractive() {
|
||||
return fmt.Errorf("cannot delete tracker pattern: confirmation required, use --yes to confirm")
|
||||
}
|
||||
|
||||
var confirmed bool
|
||||
if err := huh.NewConfirm().Title(fmt.Sprintf("Delete tracker pattern %s?", args[0])).Value(&confirmed).Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !confirmed {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -115,12 +115,15 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
if err := json.Unmarshal(data, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.Node == nil {
|
||||
return nil, fmt.Errorf("cookie category %s not found", flagCategoryID)
|
||||
}
|
||||
|
||||
if resp.Node.Typename != "CookieCategory" {
|
||||
return nil, fmt.Errorf("expected CookieCategory node, got %s", resp.Node.Typename)
|
||||
}
|
||||
|
||||
return &resp.Node.TrackerPatterns, nil
|
||||
},
|
||||
)
|
||||
@@ -143,14 +146,17 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
if p.Excluded {
|
||||
excluded = "yes"
|
||||
}
|
||||
|
||||
source := ""
|
||||
if p.Source != nil {
|
||||
source = *p.Source
|
||||
}
|
||||
|
||||
lastMatched := ""
|
||||
if p.LastMatchedAt != nil {
|
||||
lastMatched = cmdutil.FormatTime(*p.LastMatchedAt)
|
||||
}
|
||||
|
||||
rows = append(rows, []string{p.ID, p.Pattern, p.MatchType, p.TrackerType, p.DisplayName, source, excluded, lastMatched})
|
||||
}
|
||||
|
||||
|
||||
@@ -81,9 +81,11 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
if cmd.Flags().Changed("description") {
|
||||
input["description"] = flagDescription
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("max-age-seconds") {
|
||||
input["maxAgeSeconds"] = flagMaxAge
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("excluded") {
|
||||
input["excluded"] = flagExcluded
|
||||
}
|
||||
|
||||
@@ -124,16 +124,20 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Match Type:"), v.MatchType)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Tracker Type:"), v.TrackerType)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Source:"), v.Source)
|
||||
|
||||
_, _ = fmt.Fprintf(out, "%s%v\n", label.Render("Excluded:"), v.Excluded)
|
||||
if v.MaxAgeSeconds != nil {
|
||||
_, _ = fmt.Fprintf(out, "%s%d\n", label.Render("Max Age (seconds):"), *v.MaxAgeSeconds)
|
||||
}
|
||||
|
||||
if v.Description != nil && *v.Description != "" {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Description:"), *v.Description)
|
||||
}
|
||||
|
||||
if v.LastMatchedAt != nil {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Last Matched:"), cmdutil.FormatTime(*v.LastMatchedAt))
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintln(out)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Created:"), cmdutil.FormatTime(v.CreatedAt))
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Updated:"), cmdutil.FormatTime(v.UpdatedAt))
|
||||
|
||||
Reference in New Issue
Block a user