cmdhelpOptions builds the Options struct shared by JSON and markdown emitters. Centralized so both formats see the same dynamic resolver, version metadata, and homepage. Binary is derived from the root command's name rather than hardcoded so tests constructing a synthetic root (e.g. "padtest") get
(target *cobra.Command, depth int, all bool)
| 127 | // so tests constructing a synthetic root (e.g. "padtest") get a |
| 128 | // document keyed to that name. |
| 129 | func cmdhelpOptions(target *cobra.Command, depth int, all bool) cmdhelp.Options { |
| 130 | maxDepth := depth |
| 131 | if all { |
| 132 | maxDepth = -1 |
| 133 | } |
| 134 | return cmdhelp.Options{ |
| 135 | Binary: target.Root().Name(), |
| 136 | Version: fullVersion(), |
| 137 | Homepage: padHomepage, |
| 138 | MaxDepth: maxDepth, |
| 139 | Resolver: newDynamicResolver(), |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | // emitCmdhelpJSON walks the cobra command tree below `target` and emits |
| 144 | // a cmdhelp v0.1 JSON document matching schema/cmdhelp.schema.json. |
no test coverage detected