Start/stops/resume/get stopwatch
    Syntax: {command} <start|stop|resume|delete|get|list>
960523
def cmd(send, msg, args):
    

    parser = arguments.ArgParser(args['config'])
    parser.set_defaults(session=args['db'])
    subparser = parser.add_subparsers()
    start_parser = subparser.add_parser('start')
    start_parser.set_defaults(func=create_stopwatch)
    stop_parser = subparser.add_parser('stop')
    stop_parser.add_argument('id', type=int)
    stop_parser.set_defaults(func=stop_stopwatch)
    resume_parser = subparser.add_parser('resume')
    resume_parser.add_argument('id', type=int)
    resume_parser.set_defaults(func=resume_stopwatch)
    delete_parser = subparser.add_parser('delete')
    delete_parser.add_argument('id', type=int)
    delete_parser.set_defaults(func=delete_stopwatch, isadmin=args['is_admin'](args['nick']))
    get_parser = subparser.add_parser('get')
    get_parser.add_argument('id', type=int)
    get_parser.set_defaults(func=get_stopwatch)
    list_parser = subparser.add_parser('list')
    list_parser.set_defaults(func=list_stopwatch, nick=args['nick'], send=send)

    if not msg:
        send("Please specify a command.")
        return

    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return

    send(cmdargs.func(cmdargs))
1323070
def run_next(self):
        
        while 1:
            (op, obj) = self.work_queue.get()
            if op is STOP_SIGNAL:
                return
            try:
                (job_id, command_line) = obj
                try:
                    os.remove(self._job_file(job_id, JOB_FILE_COMMAND_LINE))
                except Exception:
                    log.exception("Running command but failed to delete - command may rerun on Pulsar boot.")
                # _run will not do anything if job has been cancelled.
                self._run(job_id, command_line, background=False)
            except Exception:
                log.warn("Uncaught exception running job with job_id %s" % job_id)
                traceback.print_exc()
1271231
def eval_command(self, cmd):
        
        if cmd == 'restart':
            self.restart(soft=True)
        elif cmd == 'stop':
            self.stop()
260764
function () {
			process.stdin.resume();
			process.stdin.setEncoding('utf8');
			_execCtx = [self];
			process.stdin.on('data', function (chunk) {
				var ctx = _execCtx[0],
					cmd = chunk.substr(0,chunk.length-1);

				if (cmd.substr(0,2) == '..')
				{
					cmd = 'if (_execCtx.length>1) _execCtx.shift(); undefined;'
				} else if (cmd.substr(0,1) == ':')
				{
					cmd = 'var newCtx = '+cmd.substr(1)+'; _execCtx.unshift(newCtx); undefined;';
				} else if (cmd.substr(0,1) == '/')
				{
					cmd = '';
					_execCtx = [self];
				}

				self.exec(cmd,ctx?ctx:undefined);
				return false;
			});
		}
908651
function stop(id, formatted) {
  const elapsed = timers[id].elapsed + msDiff(process.hrtime(), timers[id].start);

  clear(id);
  return formatted ? format(elapsed) : elapsed;
}
136035
def run(self, args):
        
        prog = args[0]
        if len(args) < 2:
            self.usage(prog)
            return 1

        command = args[1]
        if command == "start":
            self.start()
        elif command == "stop":
            self.stop()
        elif command == "restart":
            self.stop()
            self.start()
        else:
            self.usage(prog)
            return 1
        return 0
1170210
function run(params, command, callback)
{
  var job;

  // decouple commands
  command = clone(command);

  // start command execution and get job reference
  job = executioner(command, stringify(extend(this, params)), this.options || {}, callback);

  // make ready to call task termination function
  return partial(executioner.terminate, job);
}
1087884
def reset_bunch_counter(self):
        '''
        '''
        logging.info('')
        commands = []
        commands.extend(self.register.get_commands("RunMode"))
        commands.extend(self.register.get_commands("BCR"))
        self.send_commands(commands)
        time.sleep(0.1)
        commands = []
        commands.extend(self.register.get_commands("ConfMode"))
        self.send_commands(commands)
1175969
def cmd(commands, opts={})
      key_by = opts.delete(:key_by) || :instance_id
      results = {}
      threads = nodes.collect do |n|
        puts "result for #{n.instance_id} ==> n.ssh(#{commands.inspect}, #{opts.inspect})"
        Thread.new{ results[ n.send(key_by) ] = n.ssh(commands, opts) }
      end
      threads.each{ |aThread| aThread.join }
      results
    end
1351955
function restartOnProcess( index ) {
  log( 'Attempting to restart ' + index + '...' );

  // generate delegate function to pass with proper contexts.
  var startRequest = (function(context, index) {
    return function(cb) {
        startForeverWithIndex.call(context, index, cb);
    };
  }(this, index));

  done = this.async();
  findProcessWithIndex( index, function(process) {
    if(typeof process !== 'undefined') {
      log(forever.format(true,[process]));
      forever.restart(index, false);
      done();
    }
    else {
      log(index + ' not found in list of processes in forever. Starting new instance...');
      startRequest(done);
    }
  });
}
1188598
def cmd_nsh(self, args):
        ''''''
        usage = "Usage: nsh <start|stop|set>"
        if len(args) < 1:
            print(usage)
            return
        if args[0] == "start":
            self.mpstate.functions.input_handler = self.send
            self.started = True
            self.mpstate.rl.set_prompt("")
        elif args[0] == "stop":
            self.stop()
        elif args[0] == "set":
            self.serial_settings.command(args[1:])
        else:
            print(usage)
1068018
function processCommandLine() {
        if (commander.list) {
            listApps();
            process.exit(0);
        }

        if (!commander.app) {
            commander.help();
        }

        commander.endDate = commander.runDate ? moment(commander.runDate, 'MM/DD/YYYY').toDate() : new Date();
        commander.startDate = moment(commander.endDate).subtract(commander.runDays, 'days').toDate();
        commander.startDate.setHours(0, 0, 0, 0);
    }
756277
def handle_command(command):
  
  try:
    cmds = command.split(None, 1)
    cmd = cmds[0]
    if cmd == 'new':
      add_task(get_arg(cmds))
    elif cmd == 'done':
      mark_done(int(get_arg(cmds)))
    elif cmd == 'list':
      for task in format_tasks(list_tasks()):
        print task
    elif cmd == 'delete':
      delete_task(int(get_arg(cmds)))
    else:
      print_usage()
  except Exception, e:  # pylint: disable=broad-except
    print e
    print_usage()
891880
def cmd_gasheli(self, args):
        ''''''
        usage = "Usage: gasheli <start|stop|set>"
        if len(args) < 1:
            print(usage)
            return
        if args[0] == "start":
            self.start_motor()
        elif args[0] == "stop":
            self.stop_motor()
        elif args[0] == "set":
            self.gasheli_settings.command(args[1:])
        else:
            print(usage)
921716
function (callback) {
            callback = backpack.ensure(callback, this);

            if (!this.paused) { return callback && callback(new Error('run: not paused')); }

            // set flag that it is no longer paused and fire the stored callback for the command when it was paused
            this.paused = false;
            setTimeout(function () {
                this.__resume();
                delete this.__resume;
                this.triggers.resume(null, this.state.cursor.current());
            }.bind(this), 0);

            callback && callback();
        }
998436
private static Stopwatch get(final Stopwatch parent, final String taskTitle) {
        if (taskTitle.equals(parent.getTaskTitle())) {
            return parent;
        }

        for (final Stopwatch leaf : parent.getLeaves()) {
            final Stopwatch ret = get(leaf, taskTitle);

            if (null != ret) {
                return ret;
            }
        }

        return null;
    }
120574
def run_custom_server_command!
      pid = nil
      stopped = false
      command_thread = Thread.new do
        pid = Process.spawn(server_command)
        logger.info "Started command: #{server_command} (pid: #{pid})"

        Process.wait pid
        pid = nil
        raise Interrupt, "Server command exit unexpectedly" unless stopped
      end

      command_thread.abort_on_exception = true

      at_stop do
        stopped = true
        next if pid.nil?

        Process.kill("SIGTERM", pid)

        logger.info "Wait till process #{pid} stop..."

        tick = 0

        loop do
          tick += 0.2
          break if tick > WAIT_PROCESS

          if pid.nil?
            logger.info "Process #{pid} stopped."
            break
          end
        end
      end
    end