UNPKG

853 Btext/coffeescriptView Raw
1colors = require 'colors'
2program = require 'commander'
3packageJSON = require './package.json'
4
5program
6 .version packageJSON.version
7 .command 'configure', 'configure a project to work with deploy-state'
8 .command 'list', 'list deployments'
9 .command 'set', 'set the state on a deployment'
10 .command 'status', 'get the status of a deploy'
11 .command 'watch', 'watch the status of a deploy'
12
13class Command
14 constructor: ->
15 process.on 'uncaughtException', @die
16 {@runningCommand} = @parseOptions()
17
18 parseOptions: =>
19 program.parse process.argv
20 { runningCommand } = program
21 return { runningCommand }
22
23 run: =>
24 return if @runningCommand
25 program.outputHelp()
26 process.exit 0
27
28 die: (error) =>
29 return process.exit(0) unless error?
30 console.error error.stack
31 process.exit 1
32
33module.exports = Command