| selectedinstance = Object.assign(detectedInstance, clioverrides); | selectedinstance = Object.assign(detectedInstance, clioverrides); | ||||
| var todo = Promise.resolve(true); | var todo = Promise.resolve(true); | ||||
| try { | |||||
| chessinstances = acquirelocalinstances(selectedinstance); | |||||
| var promptkeys = { | |||||
| 'instanceName' : processedArgs._[1] | |||||
| } | |||||
| var promptkeys = { 'instanceName' : processedArgs._[1] } | |||||
| var reconfirm = { | |||||
| 'instanceName' : true | |||||
| var reconfirm = { | |||||
| 'instanceName' : selectedinstance['instanceName'] === 'chess' | |||||
| } | |||||
| var prompts = []; | |||||
| var eachPrompt = function(k, i, a){ | |||||
| // No local instances config found. We use a default initialized instance available in selectedinstance | |||||
| // Confirm those that were not supplied as user choices in runtime args and proceed to reattempt. | |||||
| if(promptkeys[k] && selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined && selectedinstance[k] === undefined | |||||
| || reconfirm[k]) { | |||||
| prompts.push(async ()=>{ | |||||
| // PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked. | |||||
| // We take a snapshot... Shallow.. !! If required deep should be used based on use case. | |||||
| // If latest altered state is required we can reerence this directly. | |||||
| // var asyncthis = Object.assign(this); | |||||
| Object.defineProperty(selectedinstance, k, getPromptableAsyncPropDescriptor(k, choices[k], promptkeys[k] || selectedinstance[k] )); | |||||
| return await selectedinstance[k] | |||||
| }) | |||||
| } | } | ||||
| delete promptkeys[k] | |||||
| } | |||||
| try { | |||||
| chessinstances = acquirelocalinstances(selectedinstance); | |||||
| initinstances(chessinstances, selectedinstance) | initinstances(chessinstances, selectedinstance) | ||||
| var instanceNameChoices = new Set(Object.keys( chessinstances) ) | var instanceNameChoices = new Set(Object.keys( chessinstances) ) | ||||
| instanceNameChoices.delete('current_run') | instanceNameChoices.delete('current_run') | ||||
| instanceNameChoices.add(selectedinstance['instanceName']) | instanceNameChoices.add(selectedinstance['instanceName']) | ||||
| instanceNameChoices.add(promptkeys['instanceName']) | |||||
| if(promptkeys['instanceName']) instanceNameChoices.add(promptkeys['instanceName']) | |||||
| var choices = { | var choices = { | ||||
| 'instanceName' : Array.from(instanceNameChoices) | 'instanceName' : Array.from(instanceNameChoices) | ||||
| , 'reposerver' : selectedinstance['reposervers'] | , 'reposerver' : selectedinstance['reposervers'] | ||||
| } | } | ||||
| var prompts = []; | |||||
| var eachPrompt = function(k, i, a){ | |||||
| // No local instances config found. We use a default initialized instance available in selectedinstance | |||||
| // Confirm those that were not supplied as user choices in runtime args and proceed to reattempt. | |||||
| if(selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined || reconfirm[k]) { | |||||
| prompts.push(async ()=>{ | |||||
| // PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked. | |||||
| // We take a snapshot... Shallow.. !! If required deep should be used based on use case. | |||||
| // If latest altered state is required we can reerence this directly. | |||||
| // var asyncthis = Object.assign(this); | |||||
| Object.defineProperty(selectedinstance, k, getPromptableAsyncPropDescriptor(k, choices[k], promptkeys[k] || selectedinstance[k] )); | |||||
| return await selectedinstance[k] | |||||
| }) | |||||
| } | |||||
| delete promptkeys[k] | |||||
| } | |||||
| Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts) | Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts) | ||||
| Object.keys(promptkeys).forEach(eachPrompt, promptkeys) | Object.keys(promptkeys).forEach(eachPrompt, promptkeys) | ||||
| } | } | ||||
| catch (e) { | catch (e) { | ||||
| console.error(e) | |||||
| // Basic keys that must be prompted and confirmed if not supplied as cmd line args. | |||||
| // PB: TODO --- This should be cmd specific interpretation of location parameters !!! | |||||
| var promptkeys = { | |||||
| 'instanceName' : processedArgs._[1] | |||||
| } | |||||
| var reconfirm = { | |||||
| 'instanceName' : true | |||||
| } | |||||
| console.error(e) // Missing chessinstances is not an error... | |||||
| initinstances(chessinstances, selectedinstance) | initinstances(chessinstances, selectedinstance) | ||||
| var instanceNameChoices = new Set(Object.keys( chessinstances) ) | var instanceNameChoices = new Set(Object.keys( chessinstances) ) | ||||
| instanceNameChoices.delete('current_run') | instanceNameChoices.delete('current_run') | ||||
| instanceNameChoices.add(selectedinstance['instanceName']) | instanceNameChoices.add(selectedinstance['instanceName']) | ||||
| instanceNameChoices.add(promptkeys['instanceName']) | |||||
| if(promptkeys['instanceName']) instanceNameChoices.add(promptkeys['instanceName']) | |||||
| var choices = { | var choices = { | ||||
| 'instanceName' : Array.from(instanceNameChoices) | 'instanceName' : Array.from(instanceNameChoices) | ||||
| , 'reposerver' : selectedinstance['reposervers'] | , 'reposerver' : selectedinstance['reposervers'] | ||||
| } | } | ||||
| var prompts = []; | |||||
| var eachPrompt = function(k, i, a){ | |||||
| // No local instances config found. We use a default initialized instance available in selectedinstance | |||||
| // Confirm those that were not supplied as user choices in runtime args and proceed to reattempt. | |||||
| if(selectedinstance[k] !== promptkeys[k] || promptkeys[k] === undefined || reconfirm[k]) { | |||||
| prompts.push(async ()=>{ | |||||
| // PB : NOTE -- Important in async cases when this needs to be in the same state as when it was invoked. | |||||
| // We take a snapshot... Shallow.. !! If required deep should be used based on use case. | |||||
| // If latest altered state is required we can reerence this directly. | |||||
| // var asyncthis = Object.assign(this); | |||||
| Object.defineProperty(selectedinstance, k, getPromptableAsyncPropDescriptor(k, choices[k], promptkeys[k] || selectedinstance[k] )); | |||||
| return await selectedinstance[k] | |||||
| }) | |||||
| } | |||||
| delete promptkeys[k] | |||||
| } | |||||
| Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts) | Object.keys(__interactve_promts).forEach(eachPrompt, __interactve_promts) | ||||
| Object.keys(promptkeys).forEach(eachPrompt, promptkeys) | Object.keys(promptkeys).forEach(eachPrompt, promptkeys) | ||||