0.0.10 • Published 8 years ago

supernom v0.0.10

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

supernom

Super simple command line parser and execution framework.

cmdnom

cmdnom = (require './supernom').cmdnom

cmdtree = do
   _help: 'Example application showing off the power of supernom'

cmdtree <<<
   task1:
      _opts:
         parameter1:
            _help: 'Specify the value for parameter1'
            _count: 1
            _required: true
         parameter2:
            _help: 'Specify the value for parameter1'
            _count: 1
            _default: 'value2'
      _help: 'Execute the example task1 task'
      _cmd: (opts) ->
         console.log "Executing task1 with parameter1: #{opts.parameter1} and parameter2: #{opts.parameter2}"

cmdtree <<<
   task2:
      _opts:
         parameter3:
            _help: 'Specify the value for parameter3'
            _count: 1
            _required: true
         parameter4:
            _help: 'Specify the value for parameter4'
            _count: 1
            _default: 'value2'
      _help: 'Execute the example task2 task'
      _cmd: (opts) ->
         console.log "Executing task2 with parameter3: #{opts.parameter3} and parameter4: #{opts.parameter4}"

# Run!
cmdnom.execute cmdtree, process.argv

storydrive

_ = require 'prelude-ls'
storydrive = (require './supernom').storydrive

cmdtree =
   "stop service {service}": (service) ->
      console.log "Stopping service #{service}..."

   "start service {service}": (service) ->
      console.log "Starting service #{service}..."

   "start host {hostname}": (hostname) ->
      console.log "Starting host #{hostname}..."

   "stop host {hostname}": (hostname) ->
      console.log "Stopping host #{hostname}..."

   "list units": ->
      console.log "Listing units..."

   "list hosts": ->
      console.log "Listing hosts..."

   "scale {service} to {number} instances": (number, service, dogs, cats) ->
      console.log "Scaling service #{service} to #{number} instances..."

   "check status of {service} on {host}": (service, host) ->
      console.log "Checking status of #{service} on #{host}..."

cmdtext = process.argv |> _.drop 2 |> _.Str.join ' '

# Run!
storydrive.execute cmdtree, cmdtext
0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

1.0.0

8 years ago