|
| 1 | +#!/usr/bin/env node |
| 2 | +/* |
| 3 | + * commander |
| 4 | + * https://github.com/mattma/ember-rocks |
| 5 | + * |
| 6 | + * Copyright (c) 2014 Matt Ma |
| 7 | + * Licensed under the MIT license. |
| 8 | + */ |
| 9 | + |
| 10 | +'use strict'; |
| 11 | + |
| 12 | +var program = require('commander'), |
| 13 | + create = require('../src/commands/new'), |
| 14 | + pkg = require('../package.json'); |
| 15 | + |
| 16 | +var output, outputStdout; |
| 17 | + |
| 18 | +outputStdout = function(data) { |
| 19 | + console.log(data.toString('utf8').trim()); |
| 20 | +}; |
| 21 | + |
| 22 | +output = function(proc) { |
| 23 | + proc.stdout.on('data', function(data) { |
| 24 | + return outputStdout(data); |
| 25 | + }); |
| 26 | + proc.stderr.on('data', function(data) { |
| 27 | + return outputStdout(data); |
| 28 | + }); |
| 29 | +}; |
| 30 | + |
| 31 | +program |
| 32 | + .version('em-cli ' + pkg.version) |
| 33 | + .usage("[command] [options]\n\n Command-Specific Help\n\n em [command] --help"); |
| 34 | + |
| 35 | +program |
| 36 | + .command('new') |
| 37 | + .description('creates a new ember application at [dirName]') |
| 38 | + .usage('[dirName] \n Ex: em new my-app') |
| 39 | + .action(create); |
| 40 | + |
| 41 | +// must be before .parse() since node's emit() is immediate |
| 42 | +program.on('--help', function(){ |
| 43 | + console.log(' Examples:'); |
| 44 | + console.log(''); |
| 45 | + console.log(' $ em new [dirName] # create a brand new Ember Application'); |
| 46 | + console.log(''); |
| 47 | +}); |
| 48 | + |
| 49 | +program.parse(process.argv); |
| 50 | + |
| 51 | + |
| 52 | +// resolve('rocks', { |
| 53 | +// basedir: process.cwd() |
| 54 | +// }, function(error, projectLocalCli) { |
| 55 | +// var cli; |
| 56 | +// if (error) { |
| 57 | +// // If there is an error, resolve could not find the ember-cli |
| 58 | +// // library from a package.json. Instead, include it from a relative |
| 59 | +// // path to this script file (which is likely a globally installed |
| 60 | +// // npm package). Most common cause for hitting this is `ember new` |
| 61 | +// cli = require('../lib/cli'); |
| 62 | +// } else { |
| 63 | +// // No error implies a projectLocalCli, which will load whatever |
| 64 | +// // version of ember-cli you have installed in a local package.json |
| 65 | +// cli = require(projectLocalCli); |
| 66 | +// } |
| 67 | + |
| 68 | +// cli({ |
| 69 | +// cliArgs: process.argv.slice(2), |
| 70 | +// inputStream: process.stdin, |
| 71 | +// outputStream: process.stdout |
| 72 | +// }).then(process.exit); |
| 73 | +// }); |
| 74 | + |
0 commit comments