@@ -85,6 +85,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
if flagOrg == "" {
|
||||
flagOrg = hc.Organization
|
||||
}
|
||||
|
||||
if flagOrg == "" {
|
||||
return fmt.Errorf("organization is required; pass --org or set a default with 'prb auth login'")
|
||||
}
|
||||
@@ -95,11 +96,13 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if flagOrigin == "" {
|
||||
if err := huh.NewInput().Title("Website origin (e.g. https://example.com)").Value(&flagOrigin).Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if flagCookiePolicyUrl == "" {
|
||||
if err := huh.NewInput().Title("Cookie policy URL").Value(&flagCookiePolicyUrl).Run(); err != nil {
|
||||
return err
|
||||
@@ -110,9 +113,11 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
if flagName == "" {
|
||||
return fmt.Errorf("name is required; pass --name or run interactively")
|
||||
}
|
||||
|
||||
if flagOrigin == "" {
|
||||
return fmt.Errorf("origin is required; pass --origin or run interactively")
|
||||
}
|
||||
|
||||
if flagCookiePolicyUrl == "" {
|
||||
return fmt.Errorf("cookie-policy-url is required; pass --cookie-policy-url or run interactively")
|
||||
}
|
||||
|
||||
@@ -43,10 +43,12 @@ func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
|
||||
if !f.IOStreams.IsInteractive() {
|
||||
return fmt.Errorf("cannot delete cookie banner: confirmation required, use --yes to confirm")
|
||||
}
|
||||
|
||||
var confirmed bool
|
||||
if err := huh.NewConfirm().Title(fmt.Sprintf("Delete cookie banner %s?", args[0])).Value(&confirmed).Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !confirmed {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
if flagOrg == "" {
|
||||
flagOrg = hc.Organization
|
||||
}
|
||||
|
||||
if flagOrg == "" {
|
||||
return fmt.Errorf("organization is required; pass --org or set a default with 'prb auth login'")
|
||||
}
|
||||
@@ -114,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("organization %s not found", flagOrg)
|
||||
}
|
||||
|
||||
if resp.Node.Typename != "Organization" {
|
||||
return nil, fmt.Errorf("expected Organization node, got %s", resp.Node.Typename)
|
||||
}
|
||||
|
||||
return &resp.Node.CookieBanners, nil
|
||||
},
|
||||
)
|
||||
|
||||
@@ -48,6 +48,7 @@ func NewCmdTranslate(f *cmdutil.Factory) *cobra.Command {
|
||||
if flagLanguage == "" {
|
||||
return fmt.Errorf("--language is required")
|
||||
}
|
||||
|
||||
if flagTranslations == "" {
|
||||
return fmt.Errorf("--translations is required")
|
||||
}
|
||||
|
||||
@@ -80,15 +80,19 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
if cmd.Flags().Changed("name") {
|
||||
input["name"] = flagName
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("cookie-policy-url") {
|
||||
input["cookiePolicyUrl"] = flagCookiePolicyUrl
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("privacy-policy-url") {
|
||||
input["privacyPolicyUrl"] = flagPrivacyPolicyUrl
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("consent-expiry-days") {
|
||||
input["consentExpiryDays"] = flagConsentExpiry
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("default-language") {
|
||||
input["defaultLanguage"] = flagDefaultLanguage
|
||||
}
|
||||
|
||||
@@ -122,10 +122,12 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("State:"), v.State)
|
||||
_, _ = fmt.Fprintf(out, "%s%d days\n", label.Render("Consent Expiry:"), v.ConsentExpiryDays)
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Default Language:"), v.DefaultLanguage)
|
||||
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Cookie Policy:"), v.CookiePolicyUrl)
|
||||
if v.PrivacyPolicyUrl != nil && *v.PrivacyPolicyUrl != "" {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Privacy Policy:"), *v.PrivacyPolicyUrl)
|
||||
}
|
||||
|
||||
_, _ = 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