MCPcopy Create free account
hub / github.com/openclaw/gogcli / Run

Method Run

internal/cmd/docs_edit.go:53–91  ·  view source on GitHub ↗
(ctx context.Context, kctx *kong.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

51}
52
53func (c *DocsWriteCmd) Run(ctx context.Context, kctx *kong.Context, flags *RootFlags) error {
54 id := strings.TrimSpace(c.DocID)
55 if id == "" {
56 return usage("empty docId")
57 }
58
59 text, err := c.resolveWriteText(ctx, kctx)
60 if err != nil {
61 return err
62 }
63 if c.Append && c.Replace {
64 return usage("--append cannot be combined with --replace")
65 }
66 if c.CheckOrphans && (!c.Markdown || !c.Replace || c.Append) {
67 return usage("--check-orphans requires --replace --markdown")
68 }
69
70 tab, tabErr := resolveTabArg(ctx, c.Tab, c.TabID)
71 if tabErr != nil {
72 return tabErr
73 }
74 c.Tab = tab
75
76 if err := c.validateDocumentStyle(); err != nil {
77 return err
78 }
79 if c.Batch != "" && (c.Markdown || c.Pageless || c.Layout.any()) {
80 return usage("--batch supports plain text writes without --pageless or layout flags")
81 }
82
83 if c.Markdown {
84 if c.Format.any() {
85 return usage("formatting flags are only supported for plain-text docs write; use markdown syntax or run docs format after writing")
86 }
87 return c.writeMarkdown(ctx, flags, id, text)
88 }
89
90 return c.writePlainText(ctx, flags, id, text)
91}
92
93func (c *DocsWriteCmd) validateDocumentStyle() error {
94 if !c.Pageless && !c.Layout.any() {

Callers

nothing calls this directly

Calls 7

resolveWriteTextMethod · 0.95
validateDocumentStyleMethod · 0.95
writeMarkdownMethod · 0.95
writePlainTextMethod · 0.95
usageFunction · 0.85
resolveTabArgFunction · 0.85
anyMethod · 0.45

Tested by

no test coverage detected