Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions shortcuts/doc/docs_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var DocsCreate = common.Shortcut{
{Name: "folder-token", Desc: "parent folder token"},
{Name: "wiki-node", Desc: "wiki node token"},
{Name: "wiki-space", Desc: "wiki space ID (use my_library for personal library)"},
{Name: "auto-table-widths", Type: "bool", Default: "true", Desc: "after create, adjust Markdown pipe-table column widths based on cell content (use --auto-table-widths=false to keep server default equal widths)"},
Comment thread
fangshuyu-768 marked this conversation as resolved.
},
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
count := 0
Expand Down Expand Up @@ -61,6 +62,11 @@ var DocsCreate = common.Shortcut{
augmentDocsCreateResult(runtime, result)

normalizeDocsUpdateResult(result, runtime.Str("markdown"))
if runtime.Bool("auto-table-widths") {
if docID, ok := resolveDocxTokenForCreateResult(runtime.CallAPI, result); ok {
applyMarkdownTableColumnWidths(runtime, docID, runtime.Str("markdown"))
Comment thread
fangshuyu-768 marked this conversation as resolved.
}
}
runtime.Out(result, nil)
return nil
},
Expand Down
12 changes: 12 additions & 0 deletions shortcuts/doc/docs_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package doc

import (
"context"
"fmt"
"strings"

"github.com/larksuite/cli/shortcuts/common"
Expand Down Expand Up @@ -42,6 +43,7 @@ var DocsUpdate = common.Shortcut{
{Name: "selection-with-ellipsis", Desc: "content locator (e.g. 'start...end')"},
{Name: "selection-by-title", Desc: "title locator (e.g. '## Section')"},
{Name: "new-title", Desc: "also update document title"},
{Name: "auto-table-widths", Type: "bool", Default: "true", Desc: "for --mode overwrite, adjust Markdown pipe-table column widths based on cell content (use --auto-table-widths=false to keep equal widths; ignored for other modes)"},
},
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
mode := runtime.Str("mode")
Expand Down Expand Up @@ -112,6 +114,16 @@ var DocsUpdate = common.Shortcut{
}

normalizeDocsUpdateResult(result, runtime.Str("markdown"))
if runtime.Str("mode") == "overwrite" && runtime.Bool("auto-table-widths") {
if docID, ok := docxTokenForUpdate(runtime, runtime.Str("doc")); ok {
applyMarkdownTableColumnWidths(runtime, docID, runtime.Str("markdown"))
} else {
fmt.Fprintln(
runtime.IO().ErrOut,
"auto-table-widths skipped: could not resolve --doc to a docx token",
)
Comment thread
fangshuyu-768 marked this conversation as resolved.
}
}
runtime.Out(result, nil)
return nil
},
Expand Down
Loading
Loading