@@ -157,9 +157,11 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
if flagTitle == "" {
|
||||
return fmt.Errorf("title is required; pass --title or run interactively")
|
||||
}
|
||||
|
||||
if flagDocumentType == "" {
|
||||
return fmt.Errorf("document type is required; pass --document-type or run interactively")
|
||||
}
|
||||
|
||||
if flagClassification == "" {
|
||||
return fmt.Errorf("classification is required; pass --classification or run interactively")
|
||||
}
|
||||
@@ -199,6 +201,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input["trustCenterVisibility"] = flagTrustCenterVisibility
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ func NewCmdDeleteDraft(f *cmdutil.Factory) *cobra.Command {
|
||||
}
|
||||
|
||||
var confirmed bool
|
||||
|
||||
err := huh.NewConfirm().
|
||||
Title(fmt.Sprintf("Delete draft for document %s?", args[0])).
|
||||
Value(&confirmed).
|
||||
@@ -54,6 +55,7 @@ func NewCmdDeleteDraft(f *cmdutil.Factory) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !confirmed {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
|
||||
}
|
||||
|
||||
var confirmed bool
|
||||
|
||||
err := huh.NewConfirm().
|
||||
Title(fmt.Sprintf("Delete document %s?", args[0])).
|
||||
Value(&confirmed).
|
||||
@@ -52,6 +53,7 @@ func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !confirmed {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ func NewCmdListApprovalDecisions(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"order-direction",
|
||||
flagOrderDir,
|
||||
@@ -116,6 +117,7 @@ func NewCmdListApprovalDecisions(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
variables["orderBy"] = map[string]any{
|
||||
"field": flagOrderBy,
|
||||
"direction": flagOrderDir,
|
||||
@@ -137,12 +139,15 @@ func NewCmdListApprovalDecisions(f *cmdutil.Factory) *cobra.Command {
|
||||
if err := json.Unmarshal(data, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.Node == nil {
|
||||
return nil, fmt.Errorf("approval quorum %s not found", args[0])
|
||||
}
|
||||
|
||||
if resp.Node.Typename != "DocumentVersionApprovalQuorum" {
|
||||
return nil, fmt.Errorf("expected DocumentVersionApprovalQuorum node, got %s", resp.Node.Typename)
|
||||
}
|
||||
|
||||
return &resp.Node.Decisions, nil
|
||||
},
|
||||
)
|
||||
|
||||
@@ -101,6 +101,7 @@ func NewCmdListApprovalQuorums(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"order-direction",
|
||||
flagOrderDir,
|
||||
@@ -108,6 +109,7 @@ func NewCmdListApprovalQuorums(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
variables["orderBy"] = map[string]any{
|
||||
"field": flagOrderBy,
|
||||
"direction": flagOrderDir,
|
||||
@@ -129,12 +131,15 @@ func NewCmdListApprovalQuorums(f *cmdutil.Factory) *cobra.Command {
|
||||
if err := json.Unmarshal(data, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.Node == nil {
|
||||
return nil, fmt.Errorf("document version %s not found", args[0])
|
||||
}
|
||||
|
||||
if resp.Node.Typename != "DocumentVersion" {
|
||||
return nil, fmt.Errorf("expected DocumentVersion node, got %s", resp.Node.Typename)
|
||||
}
|
||||
|
||||
return &resp.Node.ApprovalQuorums, nil
|
||||
},
|
||||
)
|
||||
|
||||
@@ -117,6 +117,7 @@ func NewCmdListVersions(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"order-direction",
|
||||
flagOrderDir,
|
||||
@@ -124,6 +125,7 @@ func NewCmdListVersions(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
variables["orderBy"] = map[string]any{
|
||||
"field": flagOrderBy,
|
||||
"direction": flagOrderDir,
|
||||
@@ -138,6 +140,7 @@ func NewCmdListVersions(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
variables["filter"] = map[string]any{
|
||||
"statuses": []string{flagStatus},
|
||||
}
|
||||
@@ -158,12 +161,15 @@ func NewCmdListVersions(f *cmdutil.Factory) *cobra.Command {
|
||||
if err := json.Unmarshal(data, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.Node == nil {
|
||||
return nil, fmt.Errorf("document %s not found", args[0])
|
||||
}
|
||||
|
||||
if resp.Node.Typename != "Document" {
|
||||
return nil, fmt.Errorf("expected Document node, got %s", resp.Node.Typename)
|
||||
}
|
||||
|
||||
return &resp.Node.Versions, nil
|
||||
},
|
||||
)
|
||||
|
||||
@@ -132,6 +132,7 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"order-direction",
|
||||
flagOrderDir,
|
||||
@@ -139,6 +140,7 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
variables["orderBy"] = map[string]any{
|
||||
"field": flagOrderBy,
|
||||
"direction": flagOrderDir,
|
||||
@@ -149,6 +151,7 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
if flagQuery != "" {
|
||||
filter["query"] = flagQuery
|
||||
}
|
||||
|
||||
if flagWriteMode != "" {
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"write-mode",
|
||||
@@ -157,8 +160,10 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
filter["writeModes"] = []string{flagWriteMode}
|
||||
}
|
||||
|
||||
if flagDocumentType != "" {
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"document-type",
|
||||
@@ -167,8 +172,10 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
filter["documentTypes"] = []string{flagDocumentType}
|
||||
}
|
||||
|
||||
if flagClassification != "" {
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"classification",
|
||||
@@ -177,8 +184,10 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
filter["classifications"] = []string{flagClassification}
|
||||
}
|
||||
|
||||
if flagStatus != "" {
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"status",
|
||||
@@ -187,8 +196,10 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
filter["status"] = []string{flagStatus}
|
||||
}
|
||||
|
||||
if len(filter) > 0 {
|
||||
variables["filter"] = filter
|
||||
}
|
||||
@@ -208,12 +219,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.Documents, nil
|
||||
},
|
||||
)
|
||||
@@ -235,12 +249,14 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
|
||||
title := ""
|
||||
docType := ""
|
||||
classification := ""
|
||||
|
||||
if len(doc.Versions.Edges) > 0 {
|
||||
v := doc.Versions.Edges[0].Node
|
||||
title = v.Title
|
||||
docType = v.DocumentType
|
||||
classification = v.Classification
|
||||
}
|
||||
|
||||
rows = append(rows, []string{
|
||||
doc.ID,
|
||||
title,
|
||||
|
||||
@@ -130,6 +130,7 @@ instead of publishing immediately. Approvers are ignored with --minor.`,
|
||||
v.Minor,
|
||||
v.Status,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -99,9 +99,11 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
if cmd.Flags().Changed("title") {
|
||||
input["title"] = flagTitle
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("content") {
|
||||
input["content"] = flagContent
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("document-type") {
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"document-type",
|
||||
@@ -110,8 +112,10 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input["documentType"] = flagDocumentType
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("classification") {
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"classification",
|
||||
@@ -120,8 +124,10 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input["classification"] = flagClassification
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("trust-center-visibility") {
|
||||
if err := cmdutil.ValidateEnum(
|
||||
"trust-center-visibility",
|
||||
@@ -130,6 +136,7 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input["trustCenterVisibility"] = flagTrustCenterVisibility
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ func NewCmdViewApprovalDecision(f *cmdutil.Factory) *cobra.Command {
|
||||
if d.DecidedAt != nil {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Decided:"), cmdutil.FormatTime(*d.DecidedAt))
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Created:"), cmdutil.FormatTime(d.CreatedAt))
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Updated:"), cmdutil.FormatTime(d.UpdatedAt))
|
||||
|
||||
|
||||
@@ -141,6 +141,7 @@ func NewCmdViewVersion(f *cmdutil.Factory) *cobra.Command {
|
||||
if v.PublishedAt != nil {
|
||||
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Published:"), cmdutil.FormatTime(*v.PublishedAt))
|
||||
}
|
||||
|
||||
_, _ = 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