docs: function parseCliOptions(args) {
      var cmdName = path.basename(args.argv[1]);
      var parser, option, commonOpts, shortOpts;
  
      assert.object(args, 'args');
      assert.object(args.argv, 'args.argv');
      assert.object(args.env, 'args.env');
      assert.object(args.errstream, 'args.errstream');
      assert.string(args.extraOptStr, 'args.extraOptStr');
      assert.object(args.clientOptions, 'args.clientOptions');
      assert.func(args.onUsage, 'args.onUsage');
      assert.optionalFunc(args.onOption, 'args.onOption');
  
      if (args.extraOptStr === '') {
          assert.ok(typeof (args.onOption) != 'function');
      } else {
          assert.func(args.onUsage, 'args.onOption');
      }
  
      if (!args.clientOptions.log) {
          args.clientOptions.log = bunyan.createLogger({
              'name': cmdName,
              'level': (args.env.LOG_LEVEL || 'fatal'),
              'stream': process.stderr,
              'serializers': bunyan.stdSerializers
          });
      }
  
      /*
       * Validate that the extra option string doesn't try to override any of our
       * common options.  It's easiest to strip out long option names and then
       * check for the presence of any of our options.
       */
      shortOpts = args.extraOptStr;
      shortOpts = shortOpts.replace(/\([^)]*\)/g, '');
      commonOpts = commonOptStr;
      commonOpts = commonOpts.replace(/\([^)]*\)/g, '');
      commonOpts = commonOpts.replace(/:/g, '');
      commonOpts.split('').forEach(function (c) {
          if (shortOpts.indexOf(c) != -1) {
              throw (new VError('internal error: ' +
                  'command cannot replace option: -%s', c));
          }
      });
  
      /*
       * Parse the combination option string.
       */
      parser = new getopt.BasicParser(commonOptStr + args.extraOptStr, args.argv);
      while ((option = parser.getopt()) !== undefined) {
          switch (option.option) {
          case 'A':
          case 'b':
          case 'h':
          case 'p':
          case 'S':
          case 'v':
              if (!parseCommonCliOption(args.errstream,
                  args.clientOptions, { cmdName: cmdName }, option)) {
                  args.onUsage();
              }
              break;
  
          default:
              if (args.extraOptStr === '') {
                  args.onUsage();
              } else {
                  args.onOption(option);
              }
              break;
          }
      }
  
      /*
       * For all of our commands, we use failFast by default so that the command
       * doesn't block indefinitely if Moray is down, and we use
       * mustCloseBeforeNormalProcessExit to make sure the commands clean up after
       * themselves.
       */
      args.clientOptions.failFast = true;
      args.clientOptions.mustCloseBeforeNormalProcessExit = true;
  
      /*
       * Perform final validation of the common options.
       */
      if (!finalizeCliOptions(args.errstream, args.clientOptions, args.env)) {
          args.onUsage();
      }
  
      return (parser);
  }