'use strict'
const cli = require('../')

module.exports = new cli.Command({
  description:"displays a simple hello world command"
, name: 'hello'
, ui: 'dots'
, usage:[
    `${cli.bold("Usage:")} ${cli.get('name')} hello --interactive`
  , `${cli.bold("Usage:")} ${cli.get('name')} hello --name=john`
  , `${cli.bold("Usage:")} ${cli.get('name')} hello --name=john --name=marry --name=paul -v screaming`
  ]

, flags:{

    name:{
      type:[ String, Array ]
    , shorthand:'n'
    , description:"The name of the person to say hello to"
    , required:true
    }

  , 'nested:value' : {
      type: Number
    , shorthand: 'nv'
    , description: 'A newsted Value'
    , name: 'nested'
    }

  , excited: {
      type:Boolean
    , shorthand: 'e'
    , description:"Say hello in a very excited manner"
    , default:false
    }

  , volume:{
      type:String
    , choices:['normal', 'screaming']
    , description:"Will yell at each person"
    , default:'normal'
    , shorthand:'v'
    }

  , password: {
      type:String
    , mask:true
    , description:"unique password"
    , shorthand:'p'
    , required: false
    }
  }
, run: async function( cmd, data ){
    const ui = this.ui
    ui.start()
    var names = Array.isArray( data.name ) ? data.name : [ data.name ]
    for( var x = 0; x< names.length; x++ ){
      await new Promise((resolve) => {
        setTimeout(() => {
          let value = "Hello, " + names[x]
          if( data.excited ){
            value += '!'
          }

          ui.text = ( data.volume === 'screaming' ? value.toUpperCase() : value );
          resolve(true)
        }, 1000 * x)
      })
    }
    await new Promise((resolve, reject) => {
      setTimeout(() => {
        if (data.password) {
          ui.succeed('your password was set')
        } else {
          ui.stop()
        }
      }, 1000 * (names.length + 1))
    })

    return out
  }
});

@@ -6,16 +6,41 @@
 strict'%0A
+const os = require('os')%0A
 const cl
@@ -1152,16 +1152,257 @@
   %7D%0A  %7D%0A
+, onContent: (content) =%3E %7B%0A    // command success%0A    // content is the final output from run function%0A    // non string content is not written to stdout automatically%0A    // you could do it here%0A%0A    console.log(content.join(os.EOL))%0A  %7D%0A%0A
 , run: a
@@ -1455,23 +1455,63 @@
 s.ui
-%0A    ui.start()
+;%0A    const out = %5B%5D;%0A    ui.start('processing names');
 %0A   
@@ -1577,16 +1577,17 @@
 a.name %5D
+;
 %0A    for
@@ -1731,16 +1731,17 @@
 names%5Bx%5D
+;
 %0A       
@@ -1787,16 +1787,17 @@
 e += '!'
+;
 %0A       
@@ -1816,18 +1816,16 @@
     
-ui.text = 
+out.push
 ( da
@@ -1906,16 +1906,17 @@
 ve(true)
+;
 %0A       
@@ -1928,16 +1928,17 @@
 000 * x)
+;
 %0A      %7D
@@ -1942,111 +1942,203 @@
   %7D)
+;
 %0A    %7D%0A
+%0A
     
-await new Promise((resolve, reject) =%3E %7B%0A      setTimeout(() =%3E %7B%0A        if (data.password)
+ui.succeed('names processed successfully');%0A%0A    if (data.password) %7B%0A      await new Promise((resolve, reject) =%3E %7B%0A        ui.start('configuring password')%0A        setTimeout(() =%3E
  %7B%0A 
@@ -2194,47 +2194,26 @@
     
-%7D else %7B%0A          ui.stop()%0A        %7D%0A
+  resolve(true)%0A  
     
@@ -2252,11 +2252,151 @@
     
+  
 %7D)%0A
+    %7D%0A%0A    // anything returned from run%0A    // is emitted from the %60content%60 event%0A    // strings will automatically be written to stdout
 %0A   

fix up example hello command