Created
February 12, 2014 02:08
-
-
Save aimoriu/8948678 to your computer and use it in GitHub Desktop.
CasperJS >Using the command line学習メモ ref: http://qiita.com/aimoriu/items/1682a4fe8d065180f548
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
// removing default options passed by the Python executable | |
casper.cli.drop("cli"); | |
casper.cli.drop("casper-path"); | |
if (casper.cli.args.length === 0 && Object.keys(casper.cli.options).length === 0) { | |
casper.echo("No arg nor option passed").exit(); | |
} |
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
var casper = require("casper").create(); | |
var utils = require("utils"); | |
casper.echo("Casper CLI passed args:"); | |
//require("utils").dump(casper.cli.args); | |
utils.dump(casper.cli.args); | |
casper.echo("Casper CLI passed options:"); | |
//require("utils").dump(casper.cli.options); | |
utils.dump(casper.cli.options); | |
casper.echo("casper.cli.has(0):" + casper.cli.has(0)); | |
casper.echo("casper.cli.get(0):" + casper.cli.get(0)); | |
casper.echo("capter.cli.has(3):" + casper.cli.has(3)); | |
casper.echo("capter.cli.get(3):" + casper.cli.get(3)); | |
casper.echo("-------------------") | |
casper.cli.drop(3); | |
casper.echo(casper.cli.has(3)); | |
casper.echo(casper.cli.get(3)); | |
casper.echo("-------------------") | |
casper.echo('casper.cli.has("foo"):' + casper.cli.has("foo")); | |
casper.echo('casper.cli.get("foo"):' + casper.cli.get("foo")); | |
//casper.cli.drop("foo"); | |
casper.echo('casper.cli.has("foo"):' + casper.cli.has("foo")); | |
casper.echo('casper.cli.get("foo"):' + casper.cli.get("foo")); | |
casper.echo('casper.cli.raw.has("foo"):' + casper.cli.raw.has("foo")); | |
casper.echo('casper.cli.raw.get("foo"):' + casper.cli.raw.get("foo")); | |
casper.echo("Object.keys:[" + Object.keys(casper.cli.options) + "]"); | |
/* | |
casper.cli.drop("cli"); | |
casper.cli.drop("casper-path"); | |
if (casper.cli.args.length === 0 && Object.keys(casper.cli.options).length ===0 ){ | |
casper.echo("No arg nor option passed"); | |
} | |
*/ | |
utils.dump(casper.cli.get("foo")); | |
utils.dump(casper.cli.raw.get("foo")); | |
utils.dump(casper.cli); | |
casper.exit(); | |
//コマンドで下記のように実行する | |
//Example | |
//C:\>casperjs c:\casperjs\lianxi\CLI.js arg1 arg2 arg3 --foo=01234567 --plop=false anotherarg | |
//casperjs native options | |
//Example | |
//C:\>casperjs --verbose --log-level=debug c:\casperjs\lianxi\CLI.js | |
// | |
//phantomjs --help |
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
//casperのインスタンスを作成する | |
//utilsを使用可能にする | |
//"Casper CLI passed args:"を出力 | |
//casper.cli.argsをdump | |
//"Casper CLI passed options:"出力 | |
//casper.cli.optionsをdump | |
//1番のパラメータが存在するかをチェック | |
//1番のパラメータを取得 | |
//4番のパラメータが存在するかをチェック | |
//4番のパラメータを取得 | |
//cli.optionsに"foo"のパラメータが存在するかをチェック | |
//cli.optionsのなかの"foo"のパラメータを取得 | |
//cli.rawに"foo"のパラメータが存在するかをチェック | |
//cli.rawのなかの"foo"のパラメータを取得 | |
//cli.optionsのなかの"foo"のパラメータを削除する | |
//cli.optionsのなかの"foo"のパラメータが存在するかをチェック | |
//cli.optionsのなかの"foo"のパラメータを取得 | |
//cli.rawのなかの"foo"のパラメータを削除する | |
//cli.rawのなかの"foo"のパラメータが存在するかをチェック | |
//cli.rawのなかの"foo"のパラメータを取得 | |
// removing default options passed by the Python executable | |
//cli.optionsから"foo"を取得 | |
//cli.rawから"foo"を取得 | |
//casper.exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment