Permalink
Browse files

prepare for npm

  • Loading branch information...
shinout committed Apr 28, 2011
1 parent c1c4ae3 commit 56ac9f7ee77c7ff7f4c7d3ee4f0b56130c8cef17
Showing with 246 additions and 4 deletions.
  1. +2 −0 ArgParser.js
  2. +22 −0 LICENCE
  3. +51 −0 README.ja.md
  4. +19 −4 README.md
  5. +18 −0 package.json
  6. +54 −0 scripts/README.tpl.md
  7. +18 −0 scripts/en.lang
  8. +18 −0 scripts/ja.lang
  9. +18 −0 scripts/package.tpl.json
  10. +21 −0 scripts/umecob-command.js
  11. +5 −0 scripts/updateinfo.sh
View
@@ -97,5 +97,7 @@ ArgParser.prototype.parse = function(arr) {
});
}
+/* version */
+ArgParser.version = '0.0.1';
module.exports = ArgParser;
View
22 LICENCE
@@ -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.
View
@@ -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}
View
@@ -1,9 +1,25 @@
argparser v0.0.1
==================
+[Node.js] parse commandline-args and options
-SYNOPSIS
--------------
- /* simplest use */
+Change Log
+
+----------------
+* [0.0.1]: Release
+
+Overview
+----------------
+### Installation ###
+ git clone git://github.com/shinout/argparser.git
+
+ OR
+
+ npm install argparser
+
+### Usage ###
+ const ArgParser = require('argparser');
+
+ /* the simplest use */
/* node hoge.js --long-var -s foo bar */
var parser = new ArgParser().parse();
parser.getArgs(); // [foo, var]
@@ -33,4 +49,3 @@ SYNOPSIS
parser.parse(['-h', 'hoge', '--encoding', 'utf-8', 'index.html']);
parser.getArgs(); // [hoge, index.html]
parser.getOptions(); // {h: true, encoding: true, m: false}
-
View
@@ -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"
+}
View
@@ -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}
+
View
@@ -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'
+}
View
@@ -0,0 +1,18 @@
+{ changeLogs :
+ { "0.0.1" : "リリース"
+ }
+
+, changelog : '変更履歴'
+, _OR : 'または'
+, description : 'コマンドライン引数、オプション解析'
+, install : 'インストール方法'
+, overview : '概要'
+, usage : '使い方'
+
+
+
+, simplest_use : 'シンプルな使い方'
+, with_value : '引数つきオプションを指定'
+, parse_array : '配列を与えて解析'
+, non_val : '引数なしオプションを指定'
+}
View
@@ -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"
+}
View
@@ -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);
View
@@ -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

0 comments on commit 56ac9f7

Please sign in to comment.