Add debug flag to generate method and deploy command (#24)

diff --git a/bin/deploy.js b/bin/deploy.js
index 433bdc1..c2b2519 100755
--- a/bin/deploy.js
+++ b/bin/deploy.js
@@ -25,7 +25,7 @@
 const path = require('path')
 
 const argv = minimist(process.argv.slice(2), {
-  string: ['apihost', 'auth', 'source', 'annotation', 'annotation-file'],
+  string: ['apihost', 'auth', 'source', 'annotation', 'annotation-file', 'debug'],
   boolean: ['insecure', 'version', 'overwrite'],
   alias: { auth: 'u', insecure: 'i', version: 'v', annotation: 'a', 'annotation-file': 'A', overwrite: 'w' }
 })
@@ -46,6 +46,7 @@
   console.error('  -u, --auth KEY                    authorization KEY')
   console.error('  -v, --version                     output the composer version')
   console.error('  -w, --overwrite                   overwrite actions if already defined')
+  console.error('  --debug LIST                      comma-separated list of debug flags')
   process.exit(1)
 }
 let composition
@@ -85,7 +86,7 @@
   console.error(error)
   process.exit(400 - 256) // Bad Request
 }
-client(options).compositions.deploy(composition, argv.overwrite)
+client(options).compositions.deploy(composition, argv.overwrite, argv.debug)
   .then(actions => {
     const names = actions.map(action => action.name)
     console.log(`ok: created action${actions.length > 1 ? 's' : ''} ${names}`)
diff --git a/client.js b/client.js
index 82fbae1..2309e62 100644
--- a/client.js
+++ b/client.js
@@ -63,8 +63,8 @@
     this.actions = wsk.actions
   }
 
-  deploy (composition, overwrite) {
-    const actions = (composition.actions || []).concat(conductor.generate(composition))
+  deploy (composition, overwrite, debug) {
+    const actions = (composition.actions || []).concat(conductor.generate(composition, debug))
     return actions.reduce((promise, action) => promise.then(() => overwrite && this.actions.delete(action).catch(() => { }))
       .then(() => this.actions.create(action)), Promise.resolve())
       .then(() => actions)
diff --git a/conductor.js b/conductor.js
index 2cf9845..be3fb45 100644
--- a/conductor.js
+++ b/conductor.js
@@ -25,9 +25,10 @@
 const version = require('./package.json').version
 
 // synthesize conductor action code from composition
-function generate ({ name, composition, ast, version: composer, annotations = [] }) {
-  const code = `// generated by composer v${composer} and conductor v${version}\n\nconst composition = ${JSON.stringify(composition, null, 4)}\n\n// do not edit below this point\n\n` +
+function generate ({ name, composition, ast, version: composer, annotations = [] }, debug) {
+  let code = `// generated by composer v${composer} and conductor v${version}\n\nconst composition = ${JSON.stringify(composition, null, 4)}\n\n// do not edit below this point\n\n` +
     minify(`const main=(${main})(composition)`, { output: { max_line_len: 127 } }).code
+  if (debug) code = `process.env.DEBUG='${debug}'\n\n` + code
   annotations = annotations.concat([{ key: 'conductor', value: ast }, { key: 'composerVersion', value: composer }, { key: 'conductorVersion', value: version }])
   return { name, action: { exec: { kind: 'nodejs:default', code }, annotations } }
 }