feat: auto-update + help

This commit is contained in:
Remy Sharp 2015-07-27 22:24:38 +01:00
parent ef60842815
commit e046c3739a
2 changed files with 29 additions and 17 deletions

View File

@ -31,32 +31,25 @@ if (argv.debug) {
require('debug').enable('inliner');
}
var Inliner = require('../');
// checks for available update and returns an instance
// var updateNotifier = require('update-notifier');
// var pkg = require('../package.json');
// var notifier = updateNotifier({ pkg: pkg });
// if (notifier.update) {
// // notify using the built-in convenience method
// notifier.notify();
// }
var updateNotifier = require('update-notifier');
var pkg = require(__dirname + '/../package.json');
var notifier = updateNotifier({ pkg: pkg });
if (notifier.update) {
// notify using the built-in convenience method
notifier.notify();
}
var Inliner = require('../');
var url = argv._.shift();
var argvKeys = Object.keys(argv).filter(function (item) {
var argvKeys = Object.keys(argv).filter(function filter(item) {
return item !== '_';
});
if (!url && argvKeys.length === 0 || argv.help) {
// show USAGE!
console.log(' Examples:');
console.log('');
console.log(' $ inliner -v http://twitter.com > twitter.html');
console.log(' $ inliner -ni http://twitter.com > twitter.html');
console.log('');
console.log(' For more details see http://github.com/remy/inliner/');
console.log('');
console.log(require('fs').readFileSync(__dirname + '/../docs/usage.txt', 'utf8'));
process.exit(0);
}

19
docs/usage.txt Normal file
View File

@ -0,0 +1,19 @@
Usage:
$ inliner [options] url-or-filename
Options:
-h, --help output usage information
-V, --version output the version number
-v, --verbose echo on STDERR the progress of inlining
-n, --nocompress don't compress CSS or HTML - useful for debugging
-i, --images don't encode images - keeps files size small, but more requests
Examples:
$ inliner -v https://twitter.com > twitter.html
$ inliner -ni local-file.html > local-file.min.html
For more details see http://github.com/remy/inliner/