Commit d2e40873 d2e40873189709c7d1bf5c0d7445188ecb69ebcc by Nicolas Perriault

Merge branch 'master' of github.com:n1k0/casperjs

2 parents cc98bbae 6853db45
......@@ -6,7 +6,9 @@ casper.cli.drop "cli"
casper.cli.drop "casper-path"
if casper.cli.args.length is 0 and Object.keys(casper.cli.options).length is 0
casper.echo("Pass some args and options to see how they are handled by CasperJS").exit()
casper
.echo("Pass some args and options to see how they are handled by CasperJS")
.exit(1)
casper.echo "Casper CLI passed args:"
dump casper.cli.args
......
......@@ -6,7 +6,10 @@ casper.cli.drop("cli");
casper.cli.drop("casper-path");
if (casper.cli.args.length === 0 && Object.keys(casper.cli.options).length === 0) {
casper.echo("Pass some args and options to see how they are handled by CasperJS").exit();
casper
.echo("Pass some args and options to see how they are handled by CasperJS")
.exit(1)
;
}
casper.echo("Casper CLI passed args:");
......
""" A basic custom logging implementation. The idea is to (extremely) verbosely
log every received resource.
"""
###
A basic custom logging implementation. The idea is to (extremely) verbosely
log every received resource.
###
casper = require('casper').create
# Every time a resource is received, a new log entry is added to the stack
......
......@@ -20,8 +20,9 @@ casper.fetchScore = ->
terms = casper.cli.args # terms are passed through command-line arguments
if terms.length < 3
casper.echo 'Usage: casperjs googlematch.js term1, term2 [, term3]...'
casper.exit()
casper
.echo 'Usage: casperjs googlematch.js term1, term2 [, term3]...'
.exit(1)
scores = []
......
......@@ -21,7 +21,10 @@ casper.fetchScore = function() {
};
if (terms.length < 2) {
casper.echo('Usage: casperjs googlematch.js term1, term2 [, term3]...').exit();
casper
.echo('Usage: casperjs googlematch.js term1, term2 [, term3]...')
.exit(1)
;
}
casper.echo('Let the match begin!');
......
......@@ -8,8 +8,9 @@ casper = require('casper').create()
currentPage = 1
if casper.cli.args.length == 0
casper.echo "usage: $ casperjs my search terms"
casper.exit()
casper
.echo "usage: $ casperjs my search terms"
.exit(1)
processPage = ->
@echo "capturing page #{currentPage}"
......
......@@ -4,8 +4,10 @@ casper = require('casper').create();
currentPage = 1;
if (casper.cli.args.length === 0) {
casper.echo("usage: $ casperjs my search terms");
casper.exit();
casper
.echo("usage: $ casperjs my search terms")
.exit(1)
;
}
processPage = function() {
......@@ -37,4 +39,4 @@ casper.start('http://google.fr/', function() {
casper.then(processPage);
casper.run();
\ No newline at end of file
casper.run();
......
......@@ -3,8 +3,9 @@ url = casper.cli.get 0
metas = []
if not url
casper.echo "Usage: casperjs [url]"
casper.exit()
casper
.echo "Usage: casperjs [url]"
.exit(1)
casper.start url, ->
metas = @evaluate ->
......
......@@ -3,7 +3,10 @@ var casper = require("casper").create()
, metas = [];
if (!url) {
casper.echo('Usage: casperjs [url]').exit();
casper
.echo('Usage: casperjs [url]')
.exit(1)
;
}
casper.start(url, function() {
......
......@@ -11,8 +11,9 @@ twitterAccount = casper.cli.get 0
filename = casper.cli.get 1
if not twitterAccount or not filename or not /\.(png|jpg|pdf)$/i.test filename
casper.echo "Usage $ casperjs samples/screenshot.coffee <twitter-account> <filename.[jpg|png|pdf]>"
casper.exit()
casper
.echo "Usage $ casperjs samples/screenshot.coffee <twitter-account> <filename.[jpg|png|pdf]>"
.exit(1)
casper.start "https://twitter.com/#!/#{twitterAccount}", ->
capture = ->
......
......@@ -14,8 +14,10 @@ var twitterAccount = casper.cli.get(0);
var filename = casper.cli.get(1);
if (!twitterAccount || !filename || !/\.(png|jpg|pdf)$/i.test(filename)) {
casper.echo("Usage $ casperjs samples/screenshot.coffee <twitter-account> <filename.[jpg|png|pdf]>");
casper.exit();
casper
.echo("Usage $ casperjs samples/screenshot.coffee <twitter-account> <filename.[jpg|png|pdf]>")
.exit(1)
;
}
casper.start('https://twitter.com/#!/' + twitterAccount, function() {
......
......@@ -21,8 +21,9 @@ casper = require('casper').create
timeout = ~~casper.cli.get 0
if timeout < 1
casper.echo "You must pass a valid timeout value"
casper.exit()
casper
.echo "You must pass a valid timeout value"
.exit(1)
casper.echo "Will google.com load in less than #{timeout}ms?"
casper.options.timeout = timeout
......
......@@ -22,7 +22,10 @@ var casper = require('casper').create({
var timeout = ~~casper.cli.get(0);
if (timeout < 1) {
casper.echo('You must pass a valid timeout value').exit();
casper
.echo('You must pass a valid timeout value')
.exit(1)
;
}
casper.echo('Will google.com load in less than ' + timeout + 'ms?');
casper.options.timeout = timeout;
......@@ -31,4 +34,4 @@ casper.start('http://www.google.com/', function(self) {
self.echo('YES!', 'GREEN_BAR').exit();
});
casper.run();
\ No newline at end of file
casper.run();
......