(
key: keyof ConfigSchemas.Config,
value: ConfigSchemas.Config[K],
{
afterExec,
hover,
display: commandDisplay,
alias: commandAlias,
configValueMode: commandConfigValueMode,
isVisible: isCommandVisible,
isAvailable: isCommandAvailable,
customData: commandCustomData,
}: SubgroupProps<K>,
)
| 133 | } |
| 134 | |
| 135 | function buildSubgroupCommand<K extends keyof ConfigSchemas.Config>( |
| 136 | key: keyof ConfigSchemas.Config, |
| 137 | value: ConfigSchemas.Config[K], |
| 138 | { |
| 139 | afterExec, |
| 140 | hover, |
| 141 | display: commandDisplay, |
| 142 | alias: commandAlias, |
| 143 | configValueMode: commandConfigValueMode, |
| 144 | isVisible: isCommandVisible, |
| 145 | isAvailable: isCommandAvailable, |
| 146 | customData: commandCustomData, |
| 147 | }: SubgroupProps<K>, |
| 148 | ): Command { |
| 149 | const val = value; |
| 150 | |
| 151 | let displayString = commandDisplay?.(value); |
| 152 | |
| 153 | if (displayString === undefined) { |
| 154 | if (value === true) { |
| 155 | displayString = "on"; |
| 156 | } else if (value === false) { |
| 157 | displayString = "off"; |
| 158 | } else { |
| 159 | displayString = value.toString(); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | return { |
| 164 | id: `set${capitalizeFirstLetter(key)}${capitalizeFirstLetter( |
| 165 | val.toString(), |
| 166 | )}`, |
| 167 | display: displayString, |
| 168 | configValueMode: commandConfigValueMode?.(value), |
| 169 | alias: commandAlias?.(value) ?? undefined, |
| 170 | configValue: val, |
| 171 | visible: isCommandVisible?.(value) ?? undefined, |
| 172 | available: isCommandAvailable?.(value) ?? undefined, |
| 173 | exec: (): void => { |
| 174 | setConfig(key, val); |
| 175 | afterExec?.(val); |
| 176 | }, |
| 177 | hover: |
| 178 | hover !== undefined |
| 179 | ? (): void => { |
| 180 | hover?.(val); |
| 181 | } |
| 182 | : undefined, |
| 183 | customData: commandCustomData?.(val) ?? undefined, |
| 184 | }; |
| 185 | } |
| 186 | |
| 187 | function buildInputCommand<K extends keyof ConfigSchemas.Config>({ |
| 188 | key, |
no test coverage detected