#!/usr/bin/env node
const inquirer = require('inquirer')

const { getPredefinedStations, getCustomStations } = require('./lib/station')

const TakeOff = async () => {
  const predefinedStations = await getPredefinedStations()
  const customStations = await getCustomStations()
  const seperator = []

  if (customStations.length > 0) {
    seperator.push(new inquirer.Separator(`Found custom stations in "${process.cwd().split('/').pop()}"`))
  }

  const takeOffSteps = [{
    type: 'list',
    name: 'station',
    message: 'Choose your station',
    choices: []
      .concat(predefinedStations)
      .concat(seperator)
      .concat(customStations)
  }]

  const answers = await inquirer.prompt(takeOffSteps)

  console.log('-------', answers);
}

TakeOff()

//   const b = files.filter(file => !/(.DS_Store|_shared)/.test(file))
//
//   var questions = [{
//     type: 'list',
//     name: 'station',
//     message: 'Choose your station',
//     choices: []
//     .concat(b)
//     // if .takeoff folder found in project
//     .concat([new inquirer.Separator(`Found custom stations in "${process.cwd().split('/').pop()}"`)])
//     .concat(['A', 'B']),
//     filter: val => val.toLowerCase()
//   }]
//
//   inquirer.prompt(questions).then(function (answers) {
//     console.log('\nOrder receipt:');
//     console.log(JSON.stringify(answers));
//     });
// })




// const tasks = new Listr([{
//   title: 'Git',
// 	task: () => new Promise((resolve) => {
//     setTimeout(() => resolve(), 1000)
//   })
// },{
//   title: 'bar',
// 	task: () => new Promise((resolve) => {
//     setTimeout(() => resolve(), 2000)
//   })
// }]);
//
// tasks.run().catch(err => {
// 	console.error(err);
// });

@@ -49,16 +49,17 @@
 quirer')
+;
 %0A%0Aconst 
@@ -59,17 +59,16 @@
 %0Aconst %7B
- 
 getPrede
@@ -99,17 +99,35 @@
 Stations
- 
+, loadStationByName
 %7D = requ
@@ -146,16 +146,82 @@
 tation')
+;%0A%0Aconsole.log(%0A  require('./stations/node-module/__station__')%0A);
 %0A%0Aconst 
@@ -244,18 +244,17 @@
 () =%3E %7B%0A
-  
+%09
 const pr
@@ -297,27 +297,27 @@
 edStations()
-%0A  
+;%0A%09
 const custom
@@ -352,19 +352,19 @@
 ations()
-%0A  
+;%0A%09
 const se
@@ -375,20 +375,20 @@
 tor = %5B%5D
+;
 %0A%0A
-  
+%09
 if (cust
@@ -412,20 +412,18 @@
  %3E 0)%C2%A0%7B%0A
-    
+%09%09
 seperato
@@ -520,44 +520,59 @@
 %22%60))
-%0A  %7D%0A%0A  
+;%0A%09%7D%0A%0A%09
 const 
-takeOffStep
+chooseBetweenAvailableStation
 s = %5B%7B%0A
-    
+%09%09
 type
@@ -581,20 +581,18 @@
 'list',%0A
-    
+%09%09
 name: 's
@@ -597,23 +597,25 @@
 'station
-',%0A    
+Name',%0A%09%09
 message:
@@ -638,20 +638,18 @@
 ation',%0A
-    
+%09%09
 choices:
@@ -745,29 +745,34 @@
 ns)%0A
-  
+%09
 %7D%5D
+;
 %0A%0A
-  
+%09
 const 
-answers
+%7BstationName%7D
  = a
@@ -796,59 +796,190 @@
 mpt(
-takeOffStep
+chooseBetweenAvailableStation
 s)
+;
 %0A%0A
-  console.log('-------', answers);
+%09const station = await loadStationByName(stationName);%0A%0A%09console.log('ok the station is', station);%0A%0A  // Const answerCustomStationQuestions = %5B%5D
 %0A%7D
+;
 %0A%0ATa
@@ -989,16 +989,17 @@
 ff()
+;
 %0A%0A//   
-c
+C
 onst
@@ -1598,19 +1598,16 @@
 %0A// %7D)%0A%0A
-%0A%0A%0A
 // const

update cli