code: async function selectDelegate() {
    let result;
    let delegates = await getDelegates();
    let permissions = await getDelegatesAndPermissions();
  
    let options = ['Add new delegate'];
  
    options = options.concat(delegates.map(function (d) {
      let perm = renderTable(permissions, d.address);
  
      return `Account: ${d.address}
      Details: ${d.details}
      Permisions: ${perm}`
    }));
  
    let index = readlineSync.keyInSelect(options, 'Select a delegate:', { cancel: false });
    if (index == 0) {
      let newDelegate = await addNewDelegate();
      result = newDelegate;
    } else {
      result = delegates[index - 1].address;
    }
  
    return result;
  }
docs: Helper functions