Fixes #44 - missing examples in --help.
authorGoalSmashers <jakub@goalsmashers.com>
Sat, 16 Mar 2013 16:46:59 +0000 (17:46 +0100)
committerGoalSmashers <jakub@goalsmashers.com>
Sat, 16 Mar 2013 16:46:59 +0000 (17:46 +0100)
History.md
bin/cleancss
test/binary-test.js

index faefb1c..595d893 100644 (file)
@@ -3,6 +3,7 @@
 
 * Fixed issue [#46](https://github.com/GoalSmashers/clean-css/issues/46) - preserving special characters in URLs
   and attributes.
+* Fixed issue [#44](https://github.com/GoalSmashers/clean-css/issues/46) - examples in --help.
 
 0.10.1 / 2013-02-14
 ==================
index 640ffca..29fe083 100755 (executable)
@@ -10,6 +10,8 @@ var commands = require('commander');
 var packageConfig = fs.readFileSync(path.join(path.dirname(fs.realpathSync(process.argv[1])), '../package.json'));
 var buildVersion = JSON.parse(packageConfig).version;
 
+var isWindows = process.platform == 'win32';
+
 // Specify commander options to parse command line params correctly
 commands
   .version(buildVersion, '-v, --version')
@@ -18,8 +20,23 @@ commands
   .option('-b, --keep-line-breaks', 'Keep line breaks')
   .option('--s0', 'Remove all special comments (i.e. /*! special comment */)')
   .option('--s1', 'Remove all special comments but the first one')
-  .option('-o, --output [output-file]', 'Use [output-file] as output instead of stdout')
-  .parse(process.argv);
+  .option('-o, --output [output-file]', 'Use [output-file] as output instead of stdout');
+
+commands.on('--help', function() {
+  util.puts('  Examples:\n');
+  util.puts('    %> cleancss one.css');
+  util.puts('    %> cleancss -o one-min.css one.css');
+  if (isWindows) {
+    util.puts('    %> type one.css two.css three.css | cleancss -o merged-and-minified.css');
+  } else {
+    util.puts('    %> cat one.css two.css three.css | cleancss -o merged-and-minified.css');
+    util.puts('    %> cat one.css two.css three.css | cleancss | gzip -9 -c > merged-minified-and-gzipped.css.gz');
+  }
+  util.puts('');
+  process.exit();
+});
+
+commands.parse(process.argv);
 
 var options = {
   source: null,
index 276a238..c3a3ea7 100644 (file)
@@ -36,7 +36,16 @@ exports.commandsSuite = vows.describe('binary commands').addBatch({
   'help': binaryContext('-h', {
     'should output help': function(error, stdout) {
       assert.equal(/Usage:/.test(stdout), true);
-    }
+    },
+    'should output one file example': function(error, stdout) {
+      assert.equal(stdout.indexOf('cleancss -o one-min.css one.css') > -1, true);
+    },
+    'should output multiple files example': function(error, stdout) {
+      assert.equal(stdout.indexOf('cat one.css two.css three.css | cleancss -o merged-and-minified.css') > -1, true);
+    },
+    'should output gzipping multiple files example': function(error, stdout) {
+      assert.equal(stdout.indexOf('cat one.css two.css three.css | cleancss | gzip -9 -c > merged-minified-and-gzipped.css.gz') > -1, true);
+    },
   }),
   'version': binaryContext('-v', {
     'should output help': function(error, stdout) {