Run repl-internal commands.

    Repl-internal commands are all commands starting with ":".
172880
def handle_internal_commands(command):
    
    if command.startswith(":"):
        target = _get_registered_target(command[1:], default=None)
        if target:
            return target()
931698
def reprcall(name, args=(), kwargs=(), keywords='', sep=', ',
        argfilter=repr):
    """"""
    if keywords:
        keywords = ((', ' if (args or kwargs) else '') +
                    '**' + keywords)
    argfilter = argfilter or repr
    return "{name}({args}{sep}{kwargs}{keywords})".format(
            name=name, args=reprargs(args, filter=argfilter),
            sep=(args and kwargs) and sep or "",
            kwargs=reprkwargs(kwargs, sep), keywords=keywords or '')
1135149
def command_repo_list(self):
        
        if len(self.args) == 1 and self.args[0] == "repo-list":
            RepoList().repos()
        else:
            usage("")
1371951
def run(command, input=None, exit=0, shell=False):
        
        if isinstance(input, str):
            input = input.encode()

        # Only pipe stdin if we have input to pipe.
        stdin = {} if input is None else {"stdin": subprocess.PIPE}
        try:
            child = subprocess.Popen(command, stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE, **stdin)
        except FileNotFoundError as e:
            # Extract name of command.
            name = command.split(' ', 1)[0] if isinstance(command, str) else command[0]
            raise DependencyError(name)

        stdout, _ = child.communicate(input=input)
        if exit is not None and child.returncode != exit:
            raise Error("failed to stylecheck code")
        return stdout.decode()
1271231
def eval_command(self, cmd):
        
        if cmd == 'restart':
            self.restart(soft=True)
        elif cmd == 'stop':
            self.stop()
1071920
function replWriter(output) {
  if (output){
    if (output.constructor && output.constructor.name !== "String"){
      return util.inspect(output, {colors:true}) + '\n';
    }
  }

  return output + '\n';
}
1370369
def _RunCommand(self, command):
    """"""
    arguments = shlex.split(command)
    process = subprocess.Popen(
        arguments, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
        universal_newlines=True)
    if not process:
      raise RuntimeError("Running: {0:s} failed.".format(command))

    output, error = process.communicate()
    if process.returncode != 0:
      error = "\n".join(error.split("\n")[-5:])
      raise RuntimeError("Running: {0:s} failed with error:\n{1:s}.".format(
          command, error))

    return output
383379
def _run_command(self, cmdline):
        """"""
        try:
            if self.verbose:
                print(cmdline)
            subprocess.check_call(cmdline, shell=True)
        except subprocess.CalledProcessError:
            print('when running: ', cmdline)
            raise
937171
def run(state, command, args):
    """"""
    from ..core import do_run
    do_run(
        command=command, args=args, three=state.three, python=state.python, pypi_mirror=state.pypi_mirror
    )
213445
function loc(old, repl) {
    ['start','end','loc','range'].forEach(function (k) {
        if (k in old && !(k in repl)) 
            repl[k] = old[k];
    });
}
842869
def repl(optimize=True, persist=True):
    
    print("Extra commands for the REPL:")
    print(".code    - print code")
    print(".raw     - print raw code")
    print(".quit    - exit immediately")
    print(".reset   - reset machine (IP and stacks)")
    print(".restart - create a clean, new machine")
    print(".clear   - same as .restart")
    print(".stack   - print data stack")
    print("")

    machine = Machine([])

    def match(s, *args):
        return any(map(lambda arg: s.strip()==arg, args))

    while True:
        try:
            source = raw_input("> ").strip()

            if source[0] == "." and len(source) > 1:
                if match(source, ".quit"):
                    return
                elif match(source, ".code"):
                    print_code(machine)
                elif match(source, ".raw"):
                    print(machine.code)
                elif match(source, ".reset"):
                    machine.reset()
                elif match(source, ".restart", ".clear"):
                    machine = Machine([])
                elif match(source, ".stack"):
                    print(machine.stack)
                else:
                    raise ParseError("Unknown command: %s" % source)
                continue

            code = compile(parse(source), silent=False, optimize=optimize)

            if not persist:
                machine.reset()

            machine.code += code
            machine.run()
        except EOFError:
            return
        except KeyboardInterrupt:
            return
        except ParseError as e:
            print("Parse error: %s" % e)
        except MachineError as e:
            print("Machine error: %s" % e)
        except CompileError as e:
            print("Compile error: %s" % e)
602480
public boolean repl(boolean local) {
		try {
			String className = local ? "Local" : "Remote";
			String serviceName = local ? "$repl" : "$repl-remote";
			try {
				serviceRegistry.getService(serviceName);
				return false;
			} catch (Exception ignored) {
			}
			createService(serviceName,
					(Service) Class.forName("services.moleculer.repl." + className + "Repl").newInstance());
			return true;
		} catch (ClassNotFoundException notFound) {
			logger.error("Unable to start REPL console!");
			suggestDependency("com.github.berkesa", "moleculer-java-repl", "1.0.5");
		} catch (Exception cause) {
			logger.error("Unable to start REPL console!", cause);
		}
		return false;
	}
614469
def run(self, params):
        

        self.params = list(reversed(params))

        if not self.params:
            self.help()
            return

        while self.params:
            p = self.params.pop()

            if p in self.command:
                # If we got a known command, execute it.
                self.command[p](self)

            elif os.path.exists(p):
                # If we were given the name of an existing file, read it.
                self.read_moc(p)

            else:
                # Otherwise raise an error.
                raise CommandError('file or command {0} not found'.format(p))
54905
def command(commands)
      command = Command.new(commands)
      server.remote_expr("VimrunnerEvaluateCommandOutput('#{command}')").tap do |output|
        raise InvalidCommandError.new(output) if output =~ /^Vim(\(call\))?:E\d+:/
      end
    end
356238
def run(args)
      # Ensure Omnibus related binaries are in the PATH
      ENV["PATH"] = [File.join(base_path, "bin"),
                     File.join(base_path, "embedded","bin"),
                     ENV['PATH']].join(":")

      command_to_run = args[0]

      ## when --help is run as the command itself, we need to strip off the
      ## `--` to ensure the command maps correctly.
      if command_to_run == "--help"
        command_to_run = "help"
      end

      # This piece of code checks if the argument is an option. If it is,
      # then it sets service to nil and adds the argument into the options
      # argument. This is ugly. A better solution is having a proper parser.
      # But if we are going to implement a proper parser, we might as well
      # port this to Thor rather than reinventing Thor. For now, this preserves
      # the behavior to complain and exit with an error if one attempts to invoke
      # a pcc command that does not accept an argument. Like "help".
      options = args[2..-1] || []
      if is_option?(args[1])
        options.unshift(args[1])
        service = nil
      else
        service = args[1]
      end

      # returns either hash content of command or nil
      command = retrieve_command(command_to_run)
      if command.nil?
        log "I don't know that command."
        if args.length == 2
          log "Did you mean: #{exe_name} #{service} #{command_to_run}?"
        end
        help
        Kernel.exit 1
      end

      if args.length > 1 && command[:arity] != 2
        log "The command #{command_to_run} does not accept any arguments"
        Kernel.exit 2
      end

      parse_options options
      @force_exit = false
      exit_code = 0

      run_global_pre_hooks

      # Filter args to just command and service. If you are loading
      # custom commands and need access to the command line argument,
      # use ARGV directly.
      actual_args = [command_to_run, service].reject(&:nil?)
      if command_pre_hook(*actual_args)
        method_to_call = to_method_name(command_to_run)
        begin
          ret = send(method_to_call, *actual_args)
        rescue SystemExit => e
          @force_exit = true
          ret = e.status
        end
        command_post_hook(*actual_args)
        exit_code = ret unless ret.nil?
      else
        exit_code = 8
        @force_exit = true
      end

      if @force_exit
        Kernel.exit exit_code
      else
        exit_code
      end
    end
440662
def do(cmdline=None, runas=None):
    '''
    
    '''
    path = _pyenv_path(runas)
    cmd_split = cmdline.split()
    quoted_line = ''
    for cmd in cmd_split:
        quoted_line = quoted_line + ' ' + _cmd_quote(cmd)
    result = __salt__['cmd.run_all'](
        'env PATH={0}/shims:$PATH {1}'.format(_cmd_quote(path), quoted_line),
        runas=runas,
        python_shell=True
    )

    if result['retcode'] == 0:
        rehash(runas=runas)
        return result['stdout']
    else:
        return False
1193951
def _initiate_replset(self, port, name, maxwait=30):
        """"""
        if not self.args['replicaset'] and name != 'configRepl':
            if self.args['verbose']:
                print('Skipping replica set initialization for %s' % name)
            return

        con = self.client('localhost:%i' % port)
        try:
            rs_status = con['admin'].command({'replSetGetStatus': 1})
            return rs_status
        except OperationFailure as e:
            # not initiated yet
            for i in range(maxwait):
                try:
                    con['admin'].command({'replSetInitiate':
                                          self.config_docs[name]})
                    break
                except OperationFailure as e:
                    print(e.message + " - will retry")
                    time.sleep(1)

            if self.args['verbose']:
                print("initializing replica set '%s' with configuration: %s"
                      % (name, self.config_docs[name]))
            print("replica set '%s' initialized." % name)