Skip to content

Commit

Permalink
spy help. original opt added
Browse files Browse the repository at this point in the history
  • Loading branch information
kerbyfc committed Jan 16, 2013
1 parent 819c0e1 commit d19a81f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 43 deletions.
74 changes: 40 additions & 34 deletions bin/spy
@@ -1,23 +1,25 @@
#!/usr/bin/env node

Spier = require('../spier.js');

optkeys = {
'-i': 'ignore',
'--ignore': 'ignore',
'-d': 'dir',
'--dir': 'dir',
'-f': 'filter',
'--filter': 'filter',
'-h': 'help',
'--help' : 'help'
'-i': 'ignore',
'--ignore': 'ignore',
'-d': 'dir',
'--dir': 'dir',
'-o': 'original',
'--original': 'original',
'-f': 'filter',
'--filter': 'filter',
'-h': 'help',
'--help' : 'help'
};

keys = {
'dir': '-d --dir specify directory to spy on',
'ignore': '-i --ignore regex that explains what files will be ignored',
'filter': '-f --filter regex that explains what files will be processed. applying after --ignore',
'help': '-h --help show this message'
'dir': '• -d --dir <path> - specify directory to spy on\n',
'ignore': ' -i --ignore <regex> - explains what files will be ignored\n',
'filter': ' -f --filter <regex> - explains what files will be processed. \n NOTE: applying after -i',
'original': ' -o --original\n',
'help': ' -h --help show this message\n'
};

args = process.argv.slice(2);
Expand All @@ -38,30 +40,34 @@ while (args.length) {
};

if (options.help !== void(0) || options.dir === void(0) || options.dir === null) {
help = 'spier help: ';

help = '\n Spier help: • required\n';
for (var i in keys) {
help += '\n - ' + keys[i];
help += '\n ' + keys[i];
};
exit(help);
}
console.log(help);

spier = new Spier(options.dir, options);
} else {

ctype = function (file) {
return file.stat.isDirectory() ? 'directory' : 'file';
};
spier = new Spier(options.dir, options);

ctype = function (file) {
return file.stat.isDirectory() ? 'directory' : 'file';
};

spier.on( 'create', function (file) {
console.log( 'create' + ' ' + ctype(file) + ' ' + file.path );
});
spier.on( 'remove', function (file) {
console.log( 'remove' + ' ' + ctype(file) + ' ' + file.path );
});
spier.on( 'change', function (file) {
console.log( 'change' + ' ' + ctype(file) + ' ' + file.path );
});
spier.on( 'rename', function (from, to, file) {
console.log( 'rename', ctype(file), from, to );
});

spier.on( 'create', function (file) {
console.log( 'create' + ' ' + ctype(file) + ' ' + file.path );
});
spier.on( 'remove', function (file) {
console.log( 'remove' + ' ' + ctype(file) + ' ' + file.path );
});
spier.on( 'change', function (file) {
console.log( 'change' + ' ' + ctype(file) + ' ' + file.path );
});
spier.on( 'rename', function (from, to, file) {
console.log( 'rename', ctype(file), from, to );
});
spier.spy();

spier.spy();
}
19 changes: 10 additions & 9 deletions bin/spytest.js
@@ -1,23 +1,24 @@
#!/usr/bin/env node

Spier = require('../spier.js');

optkeys = {
'-i': 'ignore',
'--ignore': 'ignore',
'-d': 'dir',
'--dir': 'dir',
'-o': 'original',
'--original': 'original',
'-f': 'filter',
'--filter': 'filter',
'-h': 'help',
'--help' : 'help'
};

keys = {
'dir': '-d --dir • specify directory to spy',
'ignore': '-i --ignore regex that explains what files will be ignored',
'filter': '-f --filter regex that explains what files will be processed \n applying after -i',
'help': '-h --help show this message'
'dir': '• -d --dir <path> - specify directory to spy on\n',
'ignore': ' -i --ignore <regex> - explains what files will be ignored\n',
'filter': ' -f --filter <regex> - explains what files will be processed. \n NOTE: applying after -i',
'original': ' -o --original\n',
'help': ' -h --help show this message\n'
};

args = process.argv.slice(2);
Expand All @@ -29,6 +30,7 @@ while (args.length) {
arg = args.shift();
if (arg.match(/^-*/g)[0].length > 0 && optkeys[arg] !== void(0)) {
key = optkeys[arg];
console.log( key );
options[key] = null;
} else if (key) {
options[key] = arg;
Expand All @@ -40,7 +42,7 @@ if (options.help !== void(0) || options.dir === void(0) || options.dir === null)

help = '\n Spier help: • required\n';
for (var i in keys) {
help += '\n ' + keys[i] + '\n';
help += '\n ' + keys[i];
};
console.log(help);

Expand All @@ -67,5 +69,4 @@ if (options.help !== void(0) || options.dir === void(0) || options.dir === null)

spier.spy();

}

}

0 comments on commit d19a81f

Please sign in to comment.