| 186 | } |
| 187 | |
| 188 | function pathArgs(list: Part[], ps: boolean, cmd = false) { |
| 189 | if (!ps) { |
| 190 | return list |
| 191 | .slice(1) |
| 192 | .filter( |
| 193 | (item) => |
| 194 | !item.text.startsWith("-") && |
| 195 | !(cmd && item.text.startsWith("/")) && |
| 196 | !(list[0]?.text === "chmod" && item.text.startsWith("+")), |
| 197 | ) |
| 198 | .map((item) => item.text) |
| 199 | } |
| 200 | |
| 201 | const out: string[] = [] |
| 202 | let want = false |
| 203 | for (const item of list.slice(1)) { |
| 204 | if (want) { |
| 205 | out.push(item.text) |
| 206 | want = false |
| 207 | continue |
| 208 | } |
| 209 | if (item.type === "command_parameter") { |
| 210 | const flag = item.text.toLowerCase() |
| 211 | if (SWITCHES.has(flag)) continue |
| 212 | want = FLAGS.has(flag) |
| 213 | continue |
| 214 | } |
| 215 | out.push(item.text) |
| 216 | } |
| 217 | return out |
| 218 | } |
| 219 | |
| 220 | function preview(text: string) { |
| 221 | if (text.length <= MAX_METADATA_LENGTH) return text |