Skip to content

Commit

Permalink
Format the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 11, 2018
1 parent a490b1b commit 743251c
Show file tree
Hide file tree
Showing 8 changed files with 497 additions and 482 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.less]
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab
159 changes: 79 additions & 80 deletions bin/colors
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ var log = console.log;
colors.toxic();

args.filter(function (arg) {
if (arg === '-h' || arg === '--help') {
help = true;
}else if(/\-\-/.test(arg)){
styles = arg.replace('--','').split(',');
}else{
for (var i = 0; i < styles.length; i++) {
_Colors.string = arg;
if(styles[i]) scripts = _Colors[styles[i]].valueOf();
}
output += scripts;
if (arg === '-h' || arg === '--help') {
help = true;
}else if(/\-\-/.test(arg)){
styles = arg.replace('--','').split(',');
}else{
for (var i = 0; i < styles.length; i++) {
_Colors.string = arg;
if(styles[i]) scripts = _Colors[styles[i]].valueOf();
}
output += scripts;
}
})


Expand All @@ -31,101 +31,100 @@ var colors_name = _styles.colors;
var styles_name = _styles.styles;

if(help){
log('')
log('\33[2J') //清屏
log(' Usage: colors')
log('')
log(' Options:')
log('')

log(' 1.Colors Number');
log();
for (var i = 0; i < 256; i++) {
if (i !== 0 && i % 16 === 0) {
log();
process.stdout.write(' ');
}
if(i === 0)process.stdout.write(' ');
var c = new colors.Colors(wordwrap(i));
c.fgcolor_x = i;
process.stdout.write(c.valueOf());
log('')
log('\33[2J') // 清屏
log(' Usage: colors')
log('')
log(' Options:')
log('')

log(' 1.Colors Number');
log();
for (var i = 0; i < 256; i++) {
if (i !== 0 && i % 16 === 0) {
log();
process.stdout.write(' ');
}
log();
if(i === 0)process.stdout.write(' ');
var c = new colors.Colors(wordwrap(i));
c.fgcolor_x = i;
process.stdout.write(c.valueOf());
}
log();


log("")
log(" 2.styles:")
log("")
log("")
log(" 2.styles:")
log("")

styles_name.forEach(function(key) {
process.stdout.write(" "+key[key])
// log(key[key].red)
});
styles_name.forEach(function(key) {
process.stdout.write(" "+key[key])
// log(key[key].red)
});

log("")
log("")
log(" 3.colors:")
log("")
log("")
log("")
log(" 3.colors:")
log("")

colors_name.forEach(function(key) {
process.stdout.write(" "+key[key])
});
colors_name.forEach(function(key) {
process.stdout.write(" "+key[key])
});

log("")
log("")
log(" 4.background colors:")
log("")
log("")
log("")
log(" 4.background colors:")
log("")

colors_name.forEach(function(key) {
// process.stdout.write(" "+key[key+'_b'])
process.stdout.write(" "+eval( '"' +key+"_b"+ ' ".'+key+"_b"))
});
colors_name.forEach(function(key) {
// process.stdout.write(" "+key[key+'_b'])
process.stdout.write(" "+eval( '"' +key+"_b"+ ' ".'+key+"_b"))
});


log("")
log("")
log(" 5.Font Bright Color:")
log("")
log("")
log("")
log(" 5.Font Bright Color:")
log("")

colors_name.forEach(function(key) {
// process.stdout.write(" "+key[key+'_bt'])
process.stdout.write(" "+eval( '"' +key+"_bt"+ ' ".'+key+"_bt"))
});
colors_name.forEach(function(key) {
// process.stdout.write(" "+key[key+'_bt'])
process.stdout.write(" "+eval( '"' +key+"_bt"+ ' ".'+key+"_bt"))
});


log("")
log("")
log(" 6.Background Bright Color:")
log("")
log("")
log("")
log(" 6.Background Bright Color:")
log("")

colors_name.forEach(function(key) {
// process.stdout.write(" "+key[key+'_bbt'])
process.stdout.write(" "+eval( '" ' +key+"_bbt"+ ' ".'+key+"_bbt"))
});
colors_name.forEach(function(key) {
// process.stdout.write(" "+key[key+'_bbt'])
process.stdout.write(" "+eval( '" ' +key+"_bbt"+ ' ".'+key+"_bbt"))
});



log('')
log('')
log(' Examples:')
log('')
log(' colors --red "\\nhello world" --bold,underline,yellow "wcj"')
log(' colors --green,bold "\\nhello world"')
log(' colors --x12,bold "hello world"')
log('')
log('')
log('')
log(' Examples:')
log('')
log(' colors --red "\\nhello world" --bold,underline,yellow "wcj"')
log(' colors --green,bold "\\nhello world"')
log(' colors --x12,bold "hello world"')
log('')

}else{
log(output);
log(output);
}


function wordwrap(i) {
i = String(i)
return i + new Array(5 - i.length).join(' ');
i = String(i)
return i + new Array(5 - i.length).join(' ');
}



// var fs = require('fs');
// var read = fs.createReadStream;
// var write = fs.createWriteStream;
Expand Down
Loading

0 comments on commit 743251c

Please sign in to comment.