I'm attempting to pass an argument to casperJS via command line. I'm executing something like
> casperjs ..\test.js " \' { function ( var ) \' asdf"
This is loading the argument as multiple arguments
casper.cli.args[0] == "\'"
casper.cli.args[1] == "{"
casper.cli.args[2] == "function"
casper.cli.args[3] == "("
...
Notice it's a new arg everytime there's a space character - The double quotes I placed around the argument obviously don't work with the space character.
When I concat and print the arguments out I get
"\'{function(var)\'asdf"
Notice spaces all removed/truncated/whatever.
How can I escape my string so that my js app gets the actual string in 1 argument without dropping content?
Keep in mine that I need to also keep the escape integrity of the JS string I'm passing as it needs to be interpreted downstream.
I don't really understand what you want to do, if you want to get back a custom argument in your file :
Considering your command is : casperjs test yourFile.js --customArgument=" \\' { function ( var ) \\' asdf"
You get back the content in your file like that : var customArg = casper.cli.get('customArgument');
This is not what you want?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.