Adds a command to the history and reset history index.
336608
def add_command(self, command):
        
        try:
            self._history.remove(command)
        except ValueError:
            pass
        self._history.insert(0, command)
        self._index = -1
1175462
def _add(self, command, *args, **kwargs):
        
        if self.indexable:
            self.index(args)
        return self._traverse_command(command, *args, **kwargs)
244759
def handle_previous(self, command):
        
        self.result = command.items
        self._to_commit = self.result
811097
function(data) {
      // Keep the last n states (e.g. - defaults 5)
      var historyLength = _options.historyLength || 5;

      if(data) {
        _history.push(data);
      }

      // Update length
      if(_history.length > historyLength) {
        _history.splice(0, _history.length - historyLength);
      }
    }
338040
protected function appendTo($type, $command)
    {
        // Flatten one-liners
        $command = (array) $command;
        $command = array_values($command);
        $flattened = count($command) === 1 ? $command[0] : $command;

        // Format commands
        foreach ($command as $key => $entry) {
            $command[$key] = $type === 'history' ? '$ '.$entry : $entry;
        }

        $this->logs->log($command);

        // Get the various handles
        $handle = $this->getHistoryHandle();
        $history = $this->getHistory();
        $timestamp = (string) microtime(true);

        // Set new history on correct handle
        $history[$type][$timestamp] = $flattened;

        $this->history[$handle] = $history;
    }
564938
def add(self, item):
        """"""
        self._check_index()
        # Possibly truncate the history up to the current point.
        self._history = self._history[:self._index + 1]
        # Append the item
        self._history.append(item)
        # Increment the index.
        self._index += 1
        self._check_index()
        # Check that the current element is what was provided to the function.
        assert id(self.current_item) == id(item)
1136379
def do_history(self, args: argparse.Namespace) -> None:
        """"""

        # -v must be used alone with no other options
        if args.verbose:
            if args.clear or args.edit or args.output_file or args.run or args.transcript \
                    or args.expanded or args.script:
                self.poutput("-v can not be used with any other options")
                self.poutput(self.history_parser.format_usage())
                return

        # -s and -x can only be used if none of these options are present: [-c -r -e -o -t]
        if (args.script or args.expanded) \
                and (args.clear or args.edit or args.output_file or args.run or args.transcript):
            self.poutput("-s and -x can not be used with -c, -r, -e, -o, or -t")
            self.poutput(self.history_parser.format_usage())
            return

        if args.clear:
            # Clear command and readline history
            self.history.clear()

            if rl_type != RlType.NONE:
                readline.clear_history()
                if self.persistent_history_file:
                    os.remove(self.persistent_history_file)
            return

        # If an argument was supplied, then retrieve partial contents of the history
        cowardly_refuse_to_run = False
        if args.arg:
            # If a character indicating a slice is present, retrieve
            # a slice of the history
            arg = args.arg
            arg_is_int = False
            try:
                int(arg)
                arg_is_int = True
            except ValueError:
                pass

            if '..' in arg or ':' in arg:
                # Get a slice of history
                history = self.history.span(arg)
            elif arg_is_int:
                history = [self.history.get(arg)]
            elif arg.startswith(r'/') and arg.endswith(r'/'):
                history = self.history.regex_search(arg)
            else:
                history = self.history.str_search(arg)
        else:
            # If no arg given, then retrieve the entire history
            cowardly_refuse_to_run = True
            # Get a copy of the history so it doesn't get mutated while we are using it
            history = self.history[:]

        if args.run:
            if cowardly_refuse_to_run:
                self.perror("Cowardly refusing to run all previously entered commands.", traceback_war=False)
                self.perror("If this is what you want to do, specify '1:' as the range of history.",
                            traceback_war=False)
            else:
                for runme in history:
                    self.pfeedback(runme)
                    if runme:
                        self.onecmd_plus_hooks(runme)
        elif args.edit:
            import tempfile
            fd, fname = tempfile.mkstemp(suffix='.txt', text=True)
            with os.fdopen(fd, 'w') as fobj:
                for command in history:
                    if command.statement.multiline_command:
                        fobj.write('{}\n'.format(command.expanded.rstrip()))
                    else:
                        fobj.write('{}\n'.format(command))
            try:
                self.do_edit(fname)
                self.do_load(fname)
            except Exception:
                raise
            finally:
                os.remove(fname)
        elif args.output_file:
            try:
                with open(os.path.expanduser(args.output_file), 'w') as fobj:
                    for command in history:
                        if command.statement.multiline_command:
                            fobj.write('{}\n'.format(command.expanded.rstrip()))
                        else:
                            fobj.write('{}\n'.format(command))
                plural = 's' if len(history) > 1 else ''
                self.pfeedback('{} command{} saved to {}'.format(len(history), plural, args.output_file))
            except Exception as e:
                self.perror('Saving {!r} - {}'.format(args.output_file, e), traceback_war=False)
        elif args.transcript:
            self._generate_transcript(history, args.transcript)
        else:
            # Display the history items retrieved
            for hi in history:
                self.poutput(hi.pr(script=args.script, expanded=args.expanded, verbose=args.verbose))
1244394
def get(self, index: Union[int, str]) -> HistoryItem:
        
        index = int(index)
        if index == 0:
            raise IndexError('The first command in history is command 1.')
        elif index < 0:
            return self[index]
        else:
            return self[index - 1]
1336188
def save_history(self):
        """"""
        open(self.LOG_PATH, 'w').write("\n".join( \
                [to_text_string(self.pydocbrowser.url_combo.itemText(index))
                 for index in range(self.pydocbrowser.url_combo.count())]))
109753
public void clearHistory()
	{
		int channels = inArray.length;
		for (int c=0; c<channels; c++)
		{
			for (int i=0; i<HISTORYSIZE; i++)
			{
				inArray[c][i] = outArray[c][i] = 0f;
			}
		}
	}
1062945
def reset(self):
        
        self.connection.rebuild_index(
            self.index, coll_name=self.target_coll_name)
883716
def set_default_command(self, command):
        """"""
        cmd_name = command.name
        self.add_command(command)
        self.default_cmd_name = cmd_name
1220936
protected void addToHistory(V obj)
    {
        if(maxHistory < 1)
            return;
        if(history == null)
            if (maxHistory != Integer.MAX_VALUE)//we probably set it to a reasonable value
            {
                try
                {
                    history = new ArrayDeque<V>(maxHistory);
                }
                catch (Exception ex)
                {
                    //what is we cause one of the many OOM exceptiosn b/c initial history was too big?
                    //AKA we googed on being helpful
                    history = new ArrayDeque<V>();
                }
            }
            else
                history = new ArrayDeque<V>();
        if(history.size() == maxHistory)//make room
            history.removeFirst();
        history.add(obj);
    }
213567
def go_to_history(self, index):
        
        if index < len(self._working_lines):
            self.working_index = index
            self.cursor_position = len(self.text)
427851
public void addRecoverCommand() {
        StringBuilder buf = new StringBuilder();
        buf.append("(recover)");
        fifo.add(fifo.size(), buf.toString());
    }
993509
protected function registerResetCommand(): void
    {
        $this->app->singleton('orchestra.commands.tenanti.reset', function (Application $app) {
            return new ResetCommand($app->make('orchestra.tenanti'));
        });
    }
795544
def do_index_command(self, index, **options):
        """"""
        if options["interactive"]:
            logger.warning("This will permanently delete the index '%s'.", index)
            if not self._confirm_action():
                logger.warning(
                    "Aborting rebuild of index '%s' at user's request.", index
                )
                return

        try:
            delete = delete_index(index)
        except TransportError:
            delete = {}
            logger.info("Index %s does not exist, cannot be deleted.", index)
        create = create_index(index)
        update = update_index(index)

        return {"delete": delete, "create": create, "update": update}