From 0314e730e5524cf10d4dd994d7594a6a0f9c4ae4 Mon Sep 17 00:00:00 2001 From: Dan Motzenbecker Date: Sat, 19 Sep 2015 13:51:11 -0400 Subject: [PATCH] improved cli --- main.coffee | 21 +++++++++++++++------ package.json | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/main.coffee b/main.coffee index d1a84b7..56dabba 100644 --- a/main.coffee +++ b/main.coffee @@ -7,6 +7,7 @@ fs = require 'fs' crypto = require 'crypto' {execSync} = require 'child_process' +cli = require 'commander' chalk = require 'chalk' semver = require 'semver' reactInit = require 'react-native/local-cli/init' @@ -170,11 +171,19 @@ init = (projName) -> process.exit 1 -[_, _, name] = process.argv +cli.version '0.0.4' -unless name - logErr 'You must pass a project name as the first argument.' - logErr 'e.g. natal HelloWorld' - process.exit 1 +cli.command 'init ' + .description 'Create a new ClojureScript React Native project' + .action (name) -> + if typeof name isnt 'string' + logErr ''' + natal init requires a project name as the first argument. + e.g. + natal init HelloWorld + ''' -init name + init name + + +cli.parse process.argv diff --git a/package.json b/package.json index 7449659..fb05ea8 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "dependencies": { "chalk": "^1.1.1", "coffee-script": "^1.9.3", + "commander": "^2.8.1", "react-native": "^0.10.1", "semver": "^5.0.1" },