-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
246 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2011 SHIN Suzuki <shinout310@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
argparser v0.0.1 | ||
================== | ||
[Node.js] コマンドライン引数、オプション解析 | ||
|
||
変更履歴 | ||
|
||
---------------- | ||
* [0.0.1]: リリース | ||
|
||
概要 | ||
---------------- | ||
### インストール方法 ### | ||
git clone git://github.com/shinout/argparser.git | ||
|
||
または | ||
|
||
npm install argparser | ||
|
||
### 使い方 ### | ||
const ArgParser = require('argparser'); | ||
|
||
/* シンプルな使い方 */ | ||
/* node hoge.js --long-var -s foo bar */ | ||
var parser = new ArgParser().parse(); | ||
parser.getArgs(); // [foo, var] | ||
parser.getOptions(); // {long-var: true, s: true} | ||
|
||
|
||
/* 引数つきオプションを指定 */ | ||
/* node hoge.js piyo foo -h --var-with-val 392 bar */ | ||
var parser = new ArgParser(); | ||
parser.addValueOptions(['var-with-val']); | ||
parser.parse(); | ||
parser.getArgs(); // [piyo, foo, var] | ||
parser.getOptions(); // {h: true, var-with-val: 392} | ||
|
||
|
||
/* 配列を与えて解析 */ | ||
var parser = new ArgParser(); | ||
parser.addValueOptions(['encoding', 'm', 'aaa']); | ||
parser.parse(['-m', 110, '--encoding', 'utf-8', 'index.html']); | ||
parser.getArgs(); // [index.html] | ||
parser.getOptions(); // {encoding: utf-8, m: 100, aaa: false} | ||
|
||
|
||
/* 引数なしオプションを指定 */ | ||
parser.addOptions(['-h', '-t']); | ||
parser.addValueOptions(['encoding', 'm']); | ||
parser.parse(['-h', 'hoge', '--encoding', 'utf-8', 'index.html']); | ||
parser.getArgs(); // [hoge, index.html] | ||
parser.getOptions(); // {h: true, encoding: true, m: false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "argparser" | ||
, "version": "0.0.1" | ||
, "description": "object to parse commandline-args and options." | ||
, "tags": ["getopt", "arguments", "option", "getopts", "command"] | ||
, "author": "SHIN Suzuki <shinout310@gmail.com>" | ||
, "repository": | ||
{ "type": "git" | ||
, "url": "https://github.com/shinout/argparser.git" | ||
} | ||
, "bugs": {"web": "https://github.com/shinout/argparser/issues" } | ||
, "licences": | ||
[ { "type": "MIT" | ||
, "url": "https://github.com/shinout/argparser/raw/master/LICENCE" | ||
} | ||
] | ||
, "main": "./ArgParser.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
argparser v${version} | ||
================== | ||
[Node.js] ${description} | ||
|
||
${changelog} | ||
|
||
---------------- | ||
<< for (var i in changeLogs) { >> | ||
* [${i}]: ${changeLogs[i]} | ||
<< } >> | ||
|
||
${overview} | ||
---------------- | ||
### ${install} ### | ||
git clone git://github.com/shinout/argparser.git | ||
|
||
${_OR} | ||
|
||
npm install argparser | ||
|
||
### ${usage} ### | ||
const ArgParser = require('argparser'); | ||
|
||
/* ${simplest_use} */ | ||
/* node hoge.js --long-var -s foo bar */ | ||
var parser = new ArgParser().parse(); | ||
parser.getArgs(); // [foo, var] | ||
parser.getOptions(); // {long-var: true, s: true} | ||
|
||
|
||
/* ${with_value} */ | ||
/* node hoge.js piyo foo -h --var-with-val 392 bar */ | ||
var parser = new ArgParser(); | ||
parser.addValueOptions(['var-with-val']); | ||
parser.parse(); | ||
parser.getArgs(); // [piyo, foo, var] | ||
parser.getOptions(); // {h: true, var-with-val: 392} | ||
|
||
|
||
/* ${parse_array} */ | ||
var parser = new ArgParser(); | ||
parser.addValueOptions(['encoding', 'm', 'aaa']); | ||
parser.parse(['-m', 110, '--encoding', 'utf-8', 'index.html']); | ||
parser.getArgs(); // [index.html] | ||
parser.getOptions(); // {encoding: utf-8, m: 100, aaa: false} | ||
|
||
|
||
/* ${non_val} */ | ||
parser.addOptions(['-h', '-t']); | ||
parser.addValueOptions(['encoding', 'm']); | ||
parser.parse(['-h', 'hoge', '--encoding', 'utf-8', 'index.html']); | ||
parser.getArgs(); // [hoge, index.html] | ||
parser.getOptions(); // {h: true, encoding: true, m: false} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ changeLogs : | ||
{ "0.0.1" : "Release" | ||
} | ||
|
||
, changelog : 'Change Log' | ||
, _OR : 'OR' | ||
, description : 'parse commandline-args and options' | ||
, install : 'Installation' | ||
, overview : 'Overview' | ||
, usage : 'Usage' | ||
|
||
|
||
|
||
, simplest_use : 'the simplest use' | ||
, with_value : 'set options with value' | ||
, parse_array : 'parse array' | ||
, non_val : 'set non-value options' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ changeLogs : | ||
{ "0.0.1" : "リリース" | ||
} | ||
|
||
, changelog : '変更履歴' | ||
, _OR : 'または' | ||
, description : 'コマンドライン引数、オプション解析' | ||
, install : 'インストール方法' | ||
, overview : '概要' | ||
, usage : '使い方' | ||
|
||
|
||
|
||
, simplest_use : 'シンプルな使い方' | ||
, with_value : '引数つきオプションを指定' | ||
, parse_array : '配列を与えて解析' | ||
, non_val : '引数なしオプションを指定' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "argparser" | ||
, "version": "${version}" | ||
, "description": "object to parse commandline-args and options." | ||
, "tags": ["getopt", "arguments", "option", "getopts", "command"] | ||
, "author": "SHIN Suzuki <shinout310@gmail.com>" | ||
, "repository": | ||
{ "type": "git" | ||
, "url": "https://github.com/shinout/argparser.git" | ||
} | ||
, "bugs": {"web": "https://github.com/shinout/argparser/issues" } | ||
, "licences": | ||
[ { "type": "MIT" | ||
, "url": "https://github.com/shinout/argparser/raw/master/LICENCE" | ||
} | ||
] | ||
, "main": "./ArgParser.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var umecob = require("umecob"); | ||
var version = require("../ArgParser").version; | ||
var tplfile = process.argv[2]; | ||
var datafile = process.argv[3]; | ||
|
||
|
||
umecob.start('f', function(p) { | ||
p.tpl_id = __dirname + '/../' + p.tpl_id; | ||
if (p.data_id) { | ||
p.data_id = __dirname + '/../' + p.data_id; | ||
} | ||
else { | ||
p.data = {}; | ||
} | ||
}); | ||
|
||
umecob.compiler('scripts', umecob.Umecob.compiler('<','<','>','>')); | ||
var result = umecob({use: "file", tpl_id: tplfile, data_id: datafile, attach: function(data) { | ||
data.version = version | ||
},sync: true}); | ||
process.stdout.write(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
thisdir=$(dirname $0) | ||
node ${thisdir}/umecob-command.js ${thisdir}/README.tpl.md ${thisdir}/en.lang > ${thisdir}/../README.md | ||
node ${thisdir}/umecob-command.js ${thisdir}/README.tpl.md ${thisdir}/ja.lang > ${thisdir}/../README.ja.md | ||
node ${thisdir}/umecob-command.js scripts/package.tpl.json > ${thisdir}/../package.json |