android-icons
Advanced tools
| #!/usr/bin/env node | ||
| 'use strict' | ||
| var abbrev = require('abbrev') | ||
| var argv = require('minimist')(process.argv.slice(2), abbrev('help', 'version', 'size', 'format')) | ||
| var pkg = require('../package.json') | ||
| var icons = require('../') | ||
| function help () { | ||
| console.log([ | ||
| pkg.description, | ||
| '', | ||
| 'Use `--format json` to set output to JSON.', | ||
| 'Get specifc icon by size or name by using `--size`.', | ||
| '', | ||
| 'Examples:', | ||
| ' $ android-icons --size 48', | ||
| ' mdpi.png,48', | ||
| '', | ||
| ' $ android-icons --size 48 --format json', | ||
| ' {"name":"mdpi.png","width":48}', | ||
| '', | ||
| ' $ android-icons --size xhdpi', | ||
| ' xhdpi.png,96' | ||
| ].join('\n')) | ||
| } | ||
| function formatLog (icons, argv) { | ||
| var format = (argv.format || 'csv').toLowerCase() | ||
| if (format === 'json') { | ||
| return JSON.stringify(icons) | ||
| } | ||
| if (!Array.isArray(icons)) { | ||
| icons = [icons] | ||
| } | ||
| return icons.map(function (icon) { | ||
| return icon.name + ',' + icon.width | ||
| }).join('\n') | ||
| } | ||
| function cli () { | ||
| if (argv.help) return help() | ||
| if (argv.version) return console.log(pkg.version) | ||
| var options = { | ||
| size: argv.size || argv.s | ||
| } | ||
| var output = icons(options) | ||
| if (output) console.log(formatLog(output, argv)) | ||
| } | ||
| cli() |
+19
-22
| { | ||
| "name": "android-icons", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "description": "Get android icon file names and dimensions (width)", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/excellenteasy/android-icons" | ||
| "main": "index.js", | ||
| "bin": "./bin/android-icons.js", | ||
| "dependencies": { | ||
| "abbrev": "^1.0.5", | ||
| "minimist": "^1.1.0" | ||
| }, | ||
| "bin": { | ||
| "android-icons": "cli.js" | ||
| "devDependencies": { | ||
| "semantic-release": "^3.0.4", | ||
| "standard": "^3.3.2", | ||
| "tape": "^4.0.0" | ||
| }, | ||
| "author": { | ||
| "name": "David Pfahler", | ||
| "email": "david@excellenteasy.com", | ||
| "url": "http://excellenteasy.com" | ||
| }, | ||
| "author": "David Pfahler <david@excellenteasy.com>", | ||
| "engines": { | ||
| "node": ">=0.10.0" | ||
| "iojs": "^1", | ||
| "node": "^0.10", | ||
| "npm": "^2" | ||
| }, | ||
@@ -28,3 +29,3 @@ "scripts": { | ||
| "index.js", | ||
| "cli.js", | ||
| "bin/android-icons.js", | ||
| "icons.json" | ||
@@ -40,11 +41,7 @@ ], | ||
| ], | ||
| "dependencies": { | ||
| "abbrev": "^1.0.5", | ||
| "minimist": "^1.1.0" | ||
| }, | ||
| "devDependencies": { | ||
| "semantic-release": "^3.0.4", | ||
| "standard": "^3.3.2", | ||
| "tape": "^3.0.3" | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/excellenteasy/android-icons.git" | ||
| } | ||
| } |
+1
-0
@@ -5,2 +5,3 @@ # android-icons | ||
| [](https://david-dm.org/excellenteasy/android-icons#info=devDependencies) | ||
| [](https://github.com/boennemann/semantic-release) | ||
@@ -7,0 +8,0 @@ > Get android icon file names and dimensions (width) |
-53
| #!/usr/bin/env node | ||
| 'use strict' | ||
| var abbrev = require('abbrev') | ||
| var argv = require('minimist')(process.argv.slice(2), abbrev('help', 'version', 'size', 'format')) | ||
| var pkg = require('./package.json') | ||
| var icons = require('./') | ||
| function help () { | ||
| console.log([ | ||
| pkg.description, | ||
| '', | ||
| 'Use `--format json` to set output to JSON.', | ||
| 'Get specifc icon by size or name by using `--size`.', | ||
| '', | ||
| 'Examples:', | ||
| ' $ android-icons --size 48', | ||
| ' mdpi.png,48', | ||
| '', | ||
| ' $ android-icons --size 48 --format json', | ||
| ' {"name":"mdpi.png","width":48}', | ||
| '', | ||
| ' $ android-icons --size xhdpi', | ||
| ' xhdpi.png,96' | ||
| ].join('\n')) | ||
| } | ||
| function formatLog (icons, argv) { | ||
| var format = (argv.format || 'csv').toLowerCase() | ||
| if (format === 'json') { | ||
| return JSON.stringify(icons) | ||
| } | ||
| if (!Array.isArray(icons)) { | ||
| icons = [icons] | ||
| } | ||
| return icons.map(function (icon) { | ||
| return icon.name + ',' + icon.width | ||
| }).join('\n') | ||
| } | ||
| function cli () { | ||
| if (argv.help) return help() | ||
| if (argv.version) return console.log(pkg.version) | ||
| var options = { | ||
| size: argv.size || argv.s | ||
| } | ||
| var output = icons(options) | ||
| if (output) console.log(formatLog(output, argv)) | ||
| } | ||
| cli() |
7443
2.03%89
1.14%