// Prints the Use AO Menu and executes the user's choice. Using the AO as a client occurs only under this menu item (except Tests menu).
exportdefaultasyncfunctionuseAoMenu(){
constloggedIn=isLoggedIn()
console.log(`\n${headerStyle('AO')}\n`)
if(loggedIn){
console.log('Logged in as:',aoEnv('AO_CLI_SESSION_USERNAME'))
consttopPriority=awaitgetTopPriorityText()
if(topPriority){
console.log('Top priority:',topPriority)
}else{
console.log('Error contacting server, is your AO server running? AO features might not work.')
}
}
letaoMenuChoices=[]
if(loggedIn){
aoMenuChoices.push(
'Deck',
'Chat',
'Connect',
)
}
aoMenuChoices.push(
loggedIn?'Log Out':'Log In',
'Back to Main Menu'
)
letanswer
try{
answer=awaitinquirer.prompt({
name:'ao_menu',
type:'list',
message:'Please choose:',
choices:aoMenuChoices,
pageSize:aoMenuChoices.length
})
}catch(error){
if(error==='EVENT_INTERRUPTED'){
console.log('\nESC')
returnfalse
}
}
switch(answer.ao_menu){
case'Deck':
//await todoList('My Todo List', ['Add full AO install process to ao-cli in convenient format', 'Add AO server unit tests to ao-cli', 'Get groceries', 'Play music every day'])
while(awaitcardMenu()){}
break
case'Connect':
while(awaitconnectMenu()){}
break
case'Chat':
while(awaitchatMenu()){}
break
case'Log In':
console.log('\nao-cli will use the AO API to log into the AO server at',(aoEnv('AO_CLI_TARGET_HOSTNAME')||AO_DEFAULT_HOSTNAME)+'.')
awaitloginPrompt()
break
case'Log Out':
awaitlogout()
//await spinnerWait('Logging out...')
break
case'Back to Main Menu':
returnfalse
}
returntrue
}
// Prints a menu that allows you to join the global AO chatrooms