Improve write-to-file logic in compose command (#36)

diff --git a/bin/compose.js b/bin/compose.js
index a9cd01a..64aba12 100755
--- a/bin/compose.js
+++ b/bin/compose.js
@@ -54,7 +54,7 @@
   console.error('  compose composition.js [flags]')
   console.error('Flags:')
   console.error('  --ast                  only output the ast for the composition')
-  console.error('  --file                 write output to .json file with path and name matching input file')
+  console.error('  --file                 write output to a file next to the input file')
   console.error('  --js                   output the conductor action code for the composition')
   console.error('  -o FILE                write output to FILE')
   console.error('  -v, --version          output the composer version')
@@ -63,6 +63,7 @@
 }
 
 let composition
+let file
 try {
   composition = composer.parse(require(path.resolve(argv._[0]))) // load and validate composition
   composition = composition.compile()
@@ -72,16 +73,19 @@
   process.exit(422 - 256) // Unprocessable Entity
 }
 if (argv.js) {
-  console.log(conductor.generate(composition, argv.debug).action.exec.code)
+  composition = conductor.generate(composition, argv.debug).action.exec.code
 } else {
   if (argv.ast) composition = composition.ast
   composition = JSON.stringify(composition, null, 4)
-  if (argv.o) {
-    fs.writeFileSync(argv.o, composition.concat('\n'), { encoding: 'utf8' })
-  } else if (argv.file) {
-    const { dir, name } = path.parse(argv._[0])
-    fs.writeFileSync(path.format({ dir, name, ext: '.json' }), composition.concat('\n'), { encoding: 'utf8' })
-  } else {
-    console.log(composition)
-  }
+}
+if (argv.o) {
+  file = argv.o
+} else if (argv.file) {
+  const { dir, name } = path.parse(argv._[0])
+  file = path.format({ dir, name, ext: argv.js ? '.conductor.js' : '.json' })
+}
+if (file) {
+  fs.writeFileSync(file, composition.concat('\n'), { encoding: 'utf8' })
+} else {
+  console.log(composition)
 }
diff --git a/docs/COMMANDS.md b/docs/COMMANDS.md
index ca74c80..673035c 100644
--- a/docs/COMMANDS.md
+++ b/docs/COMMANDS.md
@@ -39,21 +39,29 @@
   compose composition.js [flags]
 Flags:
   --ast                  only output the ast for the composition
+  --file                 write output to a file next to the input file
   --js                   output the conductor action code for the composition
+  -o FILE                write output to FILE
   -v, --version          output the composer version
   --debug LIST           comma-separated list of debug flags (when using --js flag)
 ```
 The `compose` command takes a Javascript module that exports a composition
 object (for example [demo.js](../samples/demo.js)) and compiles this object to a
-portable JSON format on the standard output.
+portable JSON format on the standard output or in file.
 ```
-compose demo.js > demo.json
+compose demo.js -o demo.json
 ```
 If the `--ast` option is specified, the `compose` command only outputs a JSON
 representation of the Abstract Syntax Tree for the composition.
 
 If the `--js` option is specified, the `compose` command outputs the conductor
-action code for the composition.
+action code for the composition instead of the generated JSON.
+
+If the `-o` option is used, the `compose` command outputs to the specified file.
+
+If the `--file` option is specified, the `compose` command outputs to a file
+next to the input file with a `.json` or `.conductor.js` extension (if the
+`--js` option is specified).
 
 # Deploy
 
@@ -68,6 +76,8 @@
   -A, --annotation-file KEY=FILE    add KEY annotation with FILE content
   --apihost HOST                    API HOST
   -i, --insecure                    bypass certificate checking
+  --kind KIND                       the KIND of the conductor action runtime
+  -t, --timeout LIMIT               the timeout LIMIT in milliseconds for the conductor action
   -u, --auth KEY                    authorization KEY
   -v, --version                     output the composer version
   -w, --overwrite                   overwrite actions if already defined
@@ -93,6 +103,13 @@
 them. As a result, default parameters, limits, and annotations on preexisting
 actions are lost.
 
+The `--timeout` option specifies the timeout for the conductor action.
+
+The `--kind` option specifies the kind for the conductor action runtime. By
+default, the `nodejs:default` OpenWhisk runtime is used. The chosen runtime must
+be based on Node.js. Other Node.js runtimes may or may not be compatible with
+Composer.
+
 ### Annotations
 
 The `deploy` command implicitly annotates the deployed composition action with