#!/usr/bin/env node

var oust = require('../index');
var pkg = require('../package.json');
var fs = require('fs');


var argv = require('minimist')((process.argv.slice(2)))

var printHelp = function() {
	console.log('oust');
	console.log(pkg.description);
	console.log('');
	console.log('Usage:');
	console.log('  $ oust --file <filename> --selector <selector>');
};

if(argv.h || argv.help) {
	printHelp();
	return;
}

if(argv.v || argv.version) {
	console.log(pkg.version);
	return;
}

var file = argv.f || argv.file;
var selector = argv.s || argv.selector;

fs.readFile(file, function(err, data) {
	if(err) {
		console.log('Error opening file:', err.code);
		return;
	}
	var res = oust(data, selector);
	console.log(res.join("\n"));
});



#!/usr/bin/env node

var oust = require('../index');
var pkg = require('../package.json');
var fs = require('fs');

var argv = require('minimist')((process.argv.slice(2)))

var printHelp = function() {
	console.log('oust');
	console.log(pkg.description);
	console.log('');
	console.log('Usage:');
	console.log('  $ oust <filename> <selector>');
};

if(argv.h || argv.help) {
	printHelp();
	return;
}

if(argv.v || argv.version) {
	console.log(pkg.version);
	return;
}

var file = argv._[0];
var selector = argv._[1];

fs.readFile(file, function(err, data) {
	if(err) {
		console.error('Error opening file:', err.message);
		process.exit(1);
	}
	var res = oust(data, selector);
	console.log(res.join("\n"));
});



Update CLI based on @sindresorhus feedback
Update CLI based on @sindresorhus feedback

* don't use flagged args for file and selector
* exit properly if error opening file
