Skip to content

Commit

Permalink
build CLI tool. fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean King committed Aug 2, 2015
1 parent 91c67d3 commit 958cbec
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 11 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ tree = rucksack(tree, [options]);

<br/>

###### CLI
Process CSS directly on the command line

```sh
$ rucksack src/style.css style.css [options]
```

<br/>

###### PostCSS
Rucksack is built on PostCSS, and can be used as a PostCSS plugin.

Expand All @@ -92,7 +101,7 @@ postcss([ rucksack() ])
<br/>

###### Stylus
Use Rucksack directly as a Stylus plugin with [PostStylus][poststylus]
Stylus can be used as a Stylus plugin with [PostStylus][poststylus]

```js
stylus(css).use(poststylus('rucksack-css'))
Expand Down Expand Up @@ -135,7 +144,7 @@ _Hex shortcuts for RGBA_
}
```

_One-rule `@font-face` `src` sets (expands to [FontSpring syntax][fontspring])_
_Shorthand `@font-face` src sets (becomes [FontSpring syntax][fontspring])_
```css
@font-face {
font-family: 'My Font';
Expand All @@ -152,11 +161,11 @@ _Whole library of modern easing functions_

_Powerful quantity pseudo-selectors_
```css
ul li:at-least(4) {
li:at-least(4) {
color: blue;
}

ul li:between(4,6) {
li:between(4,6) {
color: red;
}
```
Expand Down Expand Up @@ -231,11 +240,6 @@ Pass booleans to toggle optional extras on/off

--

### Documentation
Full docs coming soon!

--

### License

MIT © [Simpla][simpla]
Expand Down
59 changes: 59 additions & 0 deletions bin/cmd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env node
/*eslint no-process-exit: 0 */
'use strict';

var fs = require('fs'),
path = require('path'),
read = require('read-file-stdin'),
write = require('write-file-stdout'),
rucksack = require('../'),
opts = require('minimist');

// Set shorthand aliases for options
opts = opts(process.argv.slice(2), {
boolean: [
'autoprefixer',
'fallbacks',
'colors'
],
alias: {
h: 'help',
s: 'sourcemap',
v: 'version'
}
});

var file = opts._[0],
out = opts._[1];

// Fetch verion from package.json
if (opts.version) {
return console.log(require('../package.json').version);
}

// Pipe out help doc from help.txt
if (file === 'help' || opts.help) {
return fs.createReadStream(path.join(__dirname, '/usage.txt'))
.pipe(process.stdout)
.on('close', function() {
process.exit(1);
});
}

read(file, function(err, buf) {

if (err) {
throw err;
}

if (file) {
opts.from = file;
}

if (out) {
opts.to = out;
}

write(out, rucksack.process(String(buf), opts));

});
13 changes: 13 additions & 0 deletions bin/help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Usage: rucksack [input] [output] {OPTIONS}

Options:

--no-autoprefixer Disable automatic vendor prefixing.

--no-fallbacks Disable legacy fallbacks.

--no-colors Disable default color replacements.

--version, -v Show the version number.

--help, -h Show this help screen.
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "rucksack-css",
"version": "0.4.3",
"description": "A little bag of CSS superpowers",
"main": "index.js",
"keywords": [
"rucksack",
"postcss",
Expand All @@ -19,15 +20,22 @@
{
"name": "Sean King",
"email": "sean@simpla.io",
"web": "http://simpla.io"
"web": "https://twitter.com/seaneking"
}
],
"bugs": {
"url": "https://github.com/simplaio/rucksack/issues"
},
"bin": {
"cli": "./bin/cli"
},
"engines": {
"node": ">= 0.10.0"
},
"homepage": "https://github.com/simplaio/rucksack",
"dependencies": {
"autoprefixer": "^5.2.0",
"minimist": "^1.1.2",
"postcss": "^4.1.9",
"postcss-alias": "^0.1.0",
"postcss-clearfix": "^0.1.0",
Expand All @@ -42,7 +50,9 @@
"postcss-pseudoelements": "^2.2.0",
"postcss-quantity-queries": "^0.3.1",
"postcss-responsive-type": "^0.1.0",
"postcss-vmin": "^1.0.0"
"postcss-vmin": "^1.0.0",
"read-file-stdin": "^0.2.0",
"write-file-stdout": "0.0.2"
},
"devDependencies": {
"gulp-eslint": "^0.12.0",
Expand Down

0 comments on commit 958cbec

Please sign in to comment.