MCPcopy Index your code
hub / github.com/larksuite/cli / inlineClause

Function inlineClause

cmd/service/paramhelp.go:81–97  ·  view source on GitHub ↗

inlineClause compresses metadata prose into one help clause: markdown links keep their text, the clause cuts at the first rune in stops, whitespace collapses, trailing punctuation goes — sentence enders (the clause join adds its own) and connectors a cut can strand, like a colon introducing a list t

(s, stops string, max int)

Source from the content-addressed store, hash-verified

79// newline cut dropped — and the result caps at max runes. The two policies
80// below differ only in where they cut and how much they keep.
81func inlineClause(s, stops string, max int) string {
82 if s == "" {
83 return ""
84 }
85 s = markdownLinkRe.ReplaceAllString(s, "$1")
86 // Backquotes must go: pflag's UnquoteUsage treats a backquoted word in a
87 // flag's usage string as the flag's metavar, so a description like wiki
88 // space_id's "可替换为`my_library`" would render the flag as
89 // "--space-id my_library" instead of "--space-id string".
90 s = strings.ReplaceAll(s, "`", "")
91 if i := strings.IndexAny(s, stops); i >= 0 {
92 s = s[:i]
93 }
94 s = strings.Join(strings.Fields(s), " ")
95 s = strings.TrimRight(s, "。.::,,、")
96 return util.TruncateStrWithEllipsis(s, max)
97}
98
99// sanitizeOptionDesc is the enum-option policy: many values share one line, so
100// keep only the first clause (cut at 。 too) and stay ultra-compact.

Callers 2

sanitizeOptionDescFunction · 0.85
sanitizeFieldDescFunction · 0.85

Calls 1

TruncateStrWithEllipsisFunction · 0.92

Tested by

no test coverage detected