ja-greetings
Advanced tools
Comparing version 1.2.1 to 1.2.3
23
cli.js
#!/usr/bin/env node | ||
const app = require('./index') | ||
const yargs = require('yargs') | ||
@@ -50,3 +52,3 @@ .usage( 'Usage:\n' | ||
} | ||
else if (is_exist == false) { | ||
else if (is_exist < 1) { | ||
show_help() | ||
@@ -66,4 +68,3 @@ } | ||
function greet(item) { | ||
const module = require('./index') | ||
const greet = module.greet(item, argv) | ||
const greet = app.greet(item, argv) | ||
if (greet) console.log(greet) | ||
@@ -73,7 +74,6 @@ } | ||
function greet_all() { | ||
const module = require('./index') | ||
let greet = '' | ||
module.get_greetings().forEach((item) => { | ||
app.get_greetings().forEach((item) => { | ||
if (item === 'all') return | ||
greet = module.greet(item, argv) | ||
greet = app.greet(item, argv) | ||
if (greet) console.log(greet) | ||
@@ -89,5 +89,5 @@ }) | ||
function exist_check(argv) { | ||
const greetings = require('./index').get_greetings() | ||
const dialects = require('./index').get_dialects() | ||
const surrounds = require('./index').get_surrounds() | ||
const greetings = app.get_greetings() | ||
const dialects = app.get_dialects() | ||
const surrounds = app.get_surrounds() | ||
let ret = true | ||
@@ -97,3 +97,3 @@ | ||
// incrementing by 1 | ||
ret = greetings.indexOf(argv._[0]) + 1 | ||
ret = greetings.indexOf(convert(argv._[0])) + 1 | ||
if (argv.d && ret) ret = dialects.indexOf(argv.d) + 1 | ||
@@ -130,4 +130,1 @@ if (argv.s && ret) ret = surrounds.indexOf(argv.s) + 1 | ||
function get_options(param) { | ||
return | ||
} |
module.exports = (text, opt) => { | ||
let greeting = '' | ||
const line = text.split('\n') | ||
greeting = '\n' + top(line[0].length, opt) + text + bottom(line[0].length, opt) | ||
greeting = '\n' | ||
+ top_surround(line[0].length, opt) | ||
+ text | ||
+ bottom_surround(line[0].length, opt) | ||
@@ -10,58 +13,56 @@ return greeting | ||
function top (length, pattern) { | ||
switch(pattern) { | ||
function top_surround (length, pattern) { | ||
switch (pattern) { | ||
case 'no': | ||
return '' | ||
break | ||
case 'w-star': | ||
return new Array(Math.floor(length/2) + 3).join('☆ ') + '\n' | ||
break | ||
case 'b-star': | ||
return new Array(Math.floor(length/2) + 3).join('★ ') + '\n' | ||
break | ||
case 'slash': | ||
return new Array(Math.floor(length/3) + 3).join('/ ̄') + '\n' | ||
break | ||
case 'asterisk': | ||
return new Array(Math.floor(length/2) + 3).join('*') + '\n' | ||
break | ||
case 'w-tri': | ||
return new Array(Math.floor(length/2) + 3).join('▽ ') + '\n' | ||
break | ||
case 'b-tri': | ||
return new Array(Math.floor(length/2) + 3).join('▼ ') + '\n' | ||
break | ||
default: | ||
return new Array(length + 3).join('-') + '\n' | ||
break | ||
} | ||
} | ||
function bottom (length, pattern) { | ||
switch(pattern) { | ||
function bottom_surround (length, pattern) { | ||
switch (pattern) { | ||
case 'no': | ||
return '' | ||
break | ||
case 'w-star': | ||
return '\n' + new Array(Math.floor(length/2) + 3).join('☆ ') | ||
break | ||
case 'b-star': | ||
return '\n' + new Array(Math.floor(length/2) + 3).join('★ ') | ||
break | ||
case 'slash': | ||
return '\n' + new Array(Math.floor(length/3) + 3).join('_/') | ||
break | ||
case 'asterisk': | ||
return '\n' + new Array(Math.floor(length/2) + 3).join('*') | ||
break | ||
case 'w-tri': | ||
return '\n' + new Array(Math.floor(length/2) + 3).join('△ ') | ||
break | ||
case 'b-tri': | ||
return '\n' + new Array(Math.floor(length/2) + 3).join('▲ ') | ||
break | ||
default: | ||
return '\n' + new Array(length + 3).join('-') | ||
break | ||
} | ||
} |
{ | ||
"name": "ja-greetings", | ||
"version": "1.2.1", | ||
"version": "1.2.3", | ||
"description": "'ja-greetings' is a cli tool that displays Japanese greetings", | ||
@@ -30,3 +30,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"ava": "^0.17.0" | ||
"ava": "^0.17.0", | ||
"pify": "^2.3.0" | ||
}, | ||
@@ -33,0 +34,0 @@ "dependencies": { |
[![npm version](https://badge.fury.io/js/ja-greetings.svg)](https://badge.fury.io/js/ja-greetings) | ||
[![Build Status](https://travis-ci.org/k-kuwahara/ja-greetings.svg?branch=master)](https://travis-ci.org/k-kuwahara/ja-greetings) | ||
[![Code Climate](https://codeclimate.com/github/k-kuwahara/ja-greetings/badges/gpa.svg)](https://codeclimate.com/github/k-kuwahara/ja-greetings) | ||
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) | ||
@@ -4,0 +6,0 @@ # ja-greetings |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104
13275
2
226