code: function initCasperCli(casperArgs) {
          var baseTestsPath = fs.pathJoin(phantom.casperPath, 'tests');
  
          if (!!casperArgs.options.version) {
              return __terminate(phantom.casperVersion.toString())
          } else if (casperArgs.get(0) === "test") {
              phantom.casperScript = fs.absolute(fs.pathJoin(baseTestsPath, 'run.js'));
              phantom.casperTest = true;
              casperArgs.drop("test");
              phantom.casperScriptBaseDir = fs.dirname(casperArgs.get(0));
          } else if (casperArgs.get(0) === "selftest") {
              phantom.casperScript = fs.absolute(fs.pathJoin(baseTestsPath, 'run.js'));
              phantom.casperSelfTest = phantom.casperTest = true;
              casperArgs.options.includes = fs.pathJoin(baseTestsPath, 'selftest.js');
              if (casperArgs.args.length <= 1) {
                  casperArgs.args.push(fs.pathJoin(baseTestsPath, 'suites'));
              }
              casperArgs.drop("selftest");
              phantom.casperScriptBaseDir = fs.dirname(casperArgs.get(1) || fs.dirname(phantom.casperScript));
          } else if (casperArgs.args.length === 0 || !!casperArgs.options.help) {
              return printHelp();
          }
  
          if (!phantom.casperScript) {
              phantom.casperScript = casperArgs.get(0);
          }
  
          if (!fs.isFile(phantom.casperScript)) {
              return __die('Unable to open file: ' + phantom.casperScript);
          }
  
          if (!phantom.casperScriptBaseDir) {
              var scriptDir = fs.dirname(phantom.casperScript);
              if (scriptDir === phantom.casperScript) {
                  scriptDir = '.';
              }
              phantom.casperScriptBaseDir = fs.absolute(scriptDir);
          }
  
          // filter out the called script name from casper args
          casperArgs.drop(phantom.casperScript);
      }
docs: Initializes the CasperJS Command Line Interface.