Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
de6db3a4
...
de6db3a4c0bb481f9b99c0d288d66fb6cd626bfd
authored
2011-12-15 14:49:35 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
refs #28 - removed unused file
1 parent
4e7d7382
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
54 deletions
lib/cli.js
lib/cli.js
deleted
100644 → 0
View file @
4e7d738
/**
* Phantom args parsing utilities.
*
*/
(
function
(
phantom
)
{
phantom
.
Casper
.
Cli
=
function
()
{
/**
* Extract current named parameters passed to the phantom script through
* the command line. Named arguments are of the form --foo=bar ou --foo
*
*/
this
.
named
=
phantom
.
args
.
forEach
(
function
(
arg
)
{
if
(
arg
.
indexOf
(
'--'
)
===
0
)
{
var
match
=
/--
(
.*
)
=
(
.*
)\s?
/i
.
exec
(
arg
);
if
(
match
)
{
params
[
match
[
1
]]
=
match
[
2
];
}
else
{
var
match2
=
/--
(
.*
)\s?
/i
.
exec
(
arg
);
if
(
match2
)
{
params
[
match2
[
1
]]
=
true
;
}
}
}
});
/**
* Checks that the specified named arguments have been passed to current
* phantom script. Dies on failure by default, but you can provide an
* onError callback for hooking on fail and do what you want.
*
*/
this
.
requireNamedArgs
=
function
(
list
,
onError
)
{
var
missing
=
[],
params
=
phantom
.
extractNamedArgs
();
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
var
name
=
list
[
i
];
if
(
!
params
.
hasOwnProperty
(
name
))
{
missing
.
push
(
name
);
}
}
if
(
missing
.
length
>
0
)
{
if
(
typeof
(
onError
)
===
"function"
)
{
onError
(
missing
);
}
else
{
var
s
=
missing
.
length
>
1
?
'are'
:
'is a'
;
console
.
log
(
JSON
.
stringify
({
status
:
"error"
,
message
:
'"'
+
(
missing
.
join
(
'", "'
))
+
'" '
+
s
+
' required named parameters.'
},
null
,
' '
));
phantom
.
exit
(
1
);
}
}
};
};
})(
phantom
);
Please
register
or
sign in
to post a comment