Complete Intuitive Solution:
Consider the following command:
casperjs example.js true --foo=false
The string true
is a command line argument, while the name foo
is a command line option.
The value assigned to the name (variable) foo
is the string false
.
Command line arguments are positional and must be accessed via the index of the argument.
Command line options are named and must be accessed via the name of the option.
In other words, you could look at arguments as similar to values in a numeric array, while options are similar to key/value pairs in an associative array.
Command Line Arguments
You can access the arguments using one of the following methods:
casper.cli.get(0) // Returns Boolean true ; Slowest / Most Readable (Opinion)
casper.cli.args[0] // Returns Boolean true
casper.cli.raw.get(0) // Returns String "true"
casper.cli.raw.args[0] // Returns String "true" ; Fastest / Least Readable (Opinion)
Command Line Options
You can access the options using one of the following methods:
casper.cli.get('foo') // Returns Boolean false ; Slowest / Most Readable (Opinion)
casper.cli.options['foo'] // Returns Boolean false
casper.cli.raw.get('foo') // Returns String "false"
casper.cli.raw.options['foo'] // Returns String "false" ; Fastest / Least Readable (Opinion)
For other inquiries about CasperJS command line arguments or options, see the documentation:
http://docs.casperjs.org/en/latest/cli.html