Skip to content

Commit

Permalink
Support export of ini file
Browse files Browse the repository at this point in the history
  • Loading branch information
jednano committed Sep 18, 2014
1 parent e309896 commit e0347b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ $ codepaint infer --help
-h, --help output help information
-d, --details give a detailed report with trend scores
--ini use ini file format
Examples:
$ codepaint infer "**/*.js"
$ codepaint infer "**/*view.js" "**/*model.js"
$ codepaint infer -d "**/*.js"
$ codepaint infer --ini "**/*.js"
$ codepaint xform --help
Expand Down Expand Up @@ -215,6 +218,12 @@ Infers formatting style from all .js files under the current directory into a
single JSON object, which you can pipe out to another file if you want. It can
then be used in a transformation (below).
If you want to create an `.editorconfig` file, use the `--ini` flag:
$ codepaint infer --ini "**/*.js" > .editorconfig
Moving on to the `xform` sub-command:
$ codepaint xform "**/*.js"
This doesn't transform any files, but it does show you how many files would be
Expand Down
16 changes: 13 additions & 3 deletions bin/codepaint
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ program
.description('Infer formatting style from file(s)')
.action(infer)
.option('-d, --details', 'give a detailed report with trend scores')
.option('--ini', 'use ini file format')
.on('help', function(cmd){
cmd.outputIndented('Examples', [
'$ ' + clc.cyan('codepaint infer "**/*.js"'),
'$ codepaint infer ' + clc.cyan('"**/*view.js" "**/*model.js"')
'$ codepaint infer ' + clc.cyan('"**/*view.js" "**/*model.js"'),
'$ codepaint infer ' + clc.cyan('-d') + ' "**/*.js"',
'$ codepaint infer ' + clc.cyan('--ini') + ' "**/*.js"',
]);
}).parent

Expand Down Expand Up @@ -87,8 +90,15 @@ program


function infer(args, options) {
codepaint.infer(args.globs, options, function(style){
console.log(JSON.stringify(style));
codepaint.infer(args.globs, options, function(style) {
if (options.ini) {
console.log('[*.js]');
Object.keys(style).forEach(function(key) {
console.log(key, '=', style[key] + ';');
});
} else {
console.log(JSON.stringify(style));
}
});
}

Expand Down

0 comments on commit e0347b0

Please sign in to comment.