Added more display names + descriptions (Part 2)

This commit is contained in:
DJj123dj
2025-04-15 22:36:58 +02:00
parent e129724c12
commit 605173e788
3 changed files with 67 additions and 59 deletions
+2 -2
View File
@@ -1418,10 +1418,10 @@ export class ODCheckerCustomStructure_UniqueIdArray extends ODCheckerArrayStruct
/**The scope to push unique ids when used in this array! */
readonly usedScope: string|null
constructor(id:ODValidId, source:string, scope:string, usedScope?:string, options?:ODCheckerArrayStructureOptions){
constructor(id:ODValidId, source:string, scope:string, usedScope?:string, options?:ODCheckerArrayStructureOptions, idOptions?:Omit<ODCheckerStringStructureOptions,"minLength"|"custom">){
//add premade custom structure checker
const newOptions = options ?? {}
newOptions.propertyChecker = new ODCheckerStringStructure("opendiscord:unique-id",{minLength:1,custom:(checker,value,locationTrace,locationId,locationDocs) => {
newOptions.propertyChecker = new ODCheckerStringStructure("opendiscord:unique-id",{...(idOptions ?? {}),minLength:1,custom:(checker,value,locationTrace,locationId,locationDocs) => {
if (typeof value != "string") return false
const localLt = checker.locationTraceDeref(locationTrace)
localLt.pop()
+6 -2
View File
@@ -87,12 +87,16 @@ async function renderConfigObjectStructureSelector(checker:api.ODChecker,backFn:
terminal(ansis.bold.green("Please select which variable you would like to edit.\n")+ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"))
if (!structure.options.children) return await backFn()
if (structure.options.cliDisplayName){
terminal.gray("\nProperty: "+ansis.bold.blue(structure.options.cliDisplayName)+"\n")
terminal.gray("Description: "+ansis.bold(structure.options.cliDisplayDescription ?? "/")+"\n")
}
const list = structure.options.children.filter((child) => !child.cliHideInEditMode)
const nameList = list.map((child) => (child.checker.options.cliDisplayName ? child.checker.options.cliDisplayName : child.key))
const nameLength = utilities.getLongestLength(nameList)
const finalnameList = nameList.map((name,index) => name.padEnd(nameLength+5," ")+ansis.gray((!list[index].checker.options.cliHideDescriptionInParent && list[index].checker.options.cliDisplayDescription) ? "=> "+list[index].checker.options.cliDisplayDescription : ""))
const answer = await terminal.singleColumnMenu(finalnameList,{
leftPadding:"> ",
style:terminal.cyan,
@@ -145,7 +149,7 @@ async function renderConfigArrayStructureSelector(checker:api.ODChecker,backFn:(
terminal(ansis.bold.green("Please select what you would like to do.\n")+ansis.italic.gray("(use arrow keys to navigate, go back using escape)\n"))
if (!structure.options.propertyChecker) return await backFn()
if (typeof parentIndex == "string" || !isNaN(parentIndex)){
if (structure.options.cliDisplayName || typeof parentIndex == "string" || !isNaN(parentIndex)){
terminal.gray("\nProperty: "+ansis.bold.blue(structure.options.cliDisplayName ?? parentIndex.toString())+"\n")
terminal.gray("Description: "+ansis.bold(structure.options.cliDisplayDescription ?? "/")+"\n")
}