Permalink
Browse files

Refactorings and use .conf instead of .tpl now

  • Loading branch information...
pvorb committed Jan 21, 2012
1 parent 62cbd4d commit c42e2d4df6b2d501a11d0a649ec397d12569cbc8
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -3,26 +3,21 @@
var fs = require('fs');
var path = require('path');
-var optimist = require('optimist')
- .usage(' tpl init Create a basic configuration directory\n'
- + ' tpl [options] [file] Apply a template to a file\n'
- + ' tpl [-h|--help] Show help');
+var optimist = require('optimist');
+var usage = 'Usage:\n'
+ + ' tpl init Create a basic configuration directory\n'
+ + ' tpl [options] [file] Apply a template to a file\n'
+ + ' tpl [-h|--help] Show help';
var argv = optimist.argv;
// Show help
-if (argv.h) {
- console.log(optimist.help());
-}
-// Show help
-else if (argv._.length == 0) {
- console.log(optimist.help());
-}
+if (argv.h || argv._.length == 0)
+ return console.log(usage);
// One file at a time
-else if (argv._.length > 1) {
- console.error('tpl can only translate one file at a time.');
-}
-else if (argv._.length == 1 && argv._[0] == 'init') {
- var confdir = path.resolve(process.cwd(), '.tpl');
+if (argv._.length > 1)
+ return console.error('tpl can only translate one file at a time.');
+if (argv._.length == 1 && argv._[0] == 'init') {
+ var confdir = path.resolve(process.cwd(), '.conf');
try {
fs.mkdirSync(confdir);
fs.writeFileSync(path.resolve(confdir, 'conf.json'));
View
@@ -1,7 +1,7 @@
{
- "author": "Paul Vorbach <paul@vorb.de> (http://vorb.de/)",
"name": "tpl",
"description": "a general purpose template cli",
+ "author": "Paul Vorbach <paul@vorb.de> (http://vorb.de/)",
"tags": [
"tpl",
"template",
@@ -17,7 +17,7 @@
},
"main": "./tpl.js",
"bin": {
- "tpl": "./bin/tpl"
+ "tpl": "./bin/tpl.js"
},
"engines": {
"node": ">=0.6.0"
@@ -37,4 +37,4 @@
}
],
"devDependencies": {}
-}
+}
View
2 tpl.js
@@ -24,7 +24,7 @@ var defaultConf = {
function apply(file, opt, cb) {
// look for configuration directory
- confdir(process.cwd(), 'tpl', function(err, dir) {
+ confdir(process.cwd(), 'conf', function(err, dir) {
try {
if (err)
dir = path.resolve(__dirname, '.tpl');

0 comments on commit c42e2d4

Please sign in to comment.