docs: function handler(current, argv) {
          var cmds = pargv._commands;
          var completions = [];
          if (pargv._env.EXEC === argv[0])
              argv.shift(); // remove first arg which is app/exec name.
          var tmpCmd = pargv.getCommand(utils.first(argv)); // is first is known command.
          if (tmpCmd) { // limit to single command if known.
              cmds = {}; // set the commands to just the one known command.
              cmds[tmpCmd._name] = tmpCmd;
              var sliced_1 = argv.slice(1); // remove command name.
              var curCmdIdx_1 = 0;
              var lastCmdIdx_1 = tmpCmd._arguments.length - 1; // last index for commands.
              sliced_1.forEach(function (el, i) {
                  if (!constants_1.FLAG_EXP.test(el) && i <= lastCmdIdx_1) {
                      var prev_1 = sliced_1[i - 1] || null;
                      var prevKey = tmpCmd.isOption(prev_1);
                      if (!prevKey && !constants_1.FLAG_EXP.test(prev_1)) // could be val for option.
                          curCmdIdx_1 = i;
                  }
              });
              var curIdx = sliced_1.length - 1;
              var prevIdx = sliced_1.length - 2;
              var prev = sliced_1[prevIdx] || null;
              var isFlagPrev = prev && constants_1.FLAG_EXP.test(prev);
              var isBool = tmpCmd.isBool(prev);
              var isOption = isFlagPrev && !isBool;
              var isCommand = (curCmdIdx_1 >= 0) &&
                  (curCmdIdx_1 <= lastCmdIdx_1);
              //  !FLAG_EXP.test(sliced[curIdx])
              if (isCommand || isOption) {
                  var key = isOption ? tmpCmd.aliasToKey(prev) : tmpCmd.aliasToKey(curCmdIdx_1);
                  if (tmpCmd._completions[key])
                      completions = completions.concat(tmpCmd._completions[key]);
              }
              if (tmpCmd._completions['*']) // anon custom completions.
                  completions = completions.concat(tmpCmd._completions['*']);
          }
          else {
              var _loop_1 = function (k) {
                  var cmd = cmds[k];
                  [cmd._name].concat(cmd.aliases(cmd._name) || []) // iterate commands.
                      .forEach(function (el, i) {
                      if (!~completions.indexOf(el))
                          completions.push(el);
                  });
                  cmd._options.forEach(function (o) {
                      if (!~completions.indexOf(o))
                          completions.push(o);
                      (cmd.aliases(o) || []).forEach(function (el) {
                          if (!~completions.indexOf(el))
                              completions.push(el);
                      });
                  });
              };
              for (var k in cmds) {
                  _loop_1(k);
              }
          }
          // TODO: clunky redundant need to refactor this.
          var _options = completions.filter(function (c) { return constants_1.FLAG_EXP.test(c); });
          var _cmds = completions.filter(function (c) { return !constants_1.FLAG_EXP.test(c); });
          return _cmds.sort().concat(_options.sort());
      }