def apply(self, ui): logging.info('open command shell') mode = ui.current_buffer.typename cmdline = yield ui.prompt(prefix=':', text=self.startwith, completer=CommandLineCompleter(ui.dbman, ui.accountman, mode, ui.current_buffer, ), history=ui.commandprompthistory, ) logging.debug('CMDLINE: %s' % cmdline) # interpret and apply commandline if cmdline: # save into prompt history ui.commandprompthistory.append(cmdline) mode = ui.current_buffer.typename try: cmd = commandfactory(cmdline, mode) ui.apply_command(cmd) except CommandParseError, e: ui.notify(e.message, priority='error')
def apply(self, ui): # split commandline if necessary for cmdstring in split_commandline(self.cmdline): logging.debug('CMDSEQ: apply %s' % str(cmdstring)) # translate cmdstring into :class:`Command` try: cmd = commandfactory(cmdstring, ui.mode) # store cmdline for use with 'repeat' command if cmd.repeatable: ui.last_commandline = self.cmdline.lstrip() except CommandParseError, e: ui.notify(e.message, priority='error') return yield ui.apply_command(cmd)
def apply(self, ui): # split commandline if necessary for cmdstring in split_commandline(self.cmdline): logging.debug('CMDSEQ: apply %s' % str(cmdstring)) # translate cmdstring into :class:`Command` try: cmd = commandfactory(cmdstring, ui.mode) # store cmdline for use with 'repeat' command if cmd.repeatable: ui.last_commandline = self.cmdline.lstrip() except CommandParseError as e: ui.notify(e.message, priority='error') return yield ui.apply_command(cmd)
def apply(self, ui): logging.info("open command shell") mode = ui.mode or "global" cmpl = CommandLineCompleter(ui.dbman, mode, ui.current_buffer) cmdline = yield ui.prompt("", text=self.startwith, completer=cmpl, history=ui.commandprompthistory) logging.debug("CMDLINE: %s" % cmdline) # interpret and apply commandline if cmdline: # save into prompt history ui.commandprompthistory.append(cmdline) try: cmd = commandfactory(cmdline, mode) ui.apply_command(cmd) except CommandParseError, e: ui.notify(e.message, priority="error")
def apply(self, ui): logging.info('open command shell') mode = ui.mode or 'global' cmpl = CommandLineCompleter(ui.dbman, mode, ui.current_buffer) cmdline = yield ui.prompt( '', text=self.startwith, completer=cmpl, history=ui.commandprompthistory, ) logging.debug('CMDLINE: %s' % cmdline) # interpret and apply commandline if cmdline: # save into prompt history ui.commandprompthistory.append(cmdline) try: cmd = commandfactory(cmdline, mode) ui.apply_command(cmd) except CommandParseError, e: ui.notify(e.message, priority='error')
def apply(self, ui): for cmdstring in self.commandlist: logging.debug('CMDSEQ: apply %s' % str(cmdstring)) # translate cmdstring into :class:`Command` cmd = commandfactory(cmdstring, ui.mode) yield ui.apply_command(cmd)
settings.read_config(alotconfig) settings.read_notmuch_config(notmuchconfig) except (ConfigError, OSError, IOError), e: sys.exit(e) # store options given by config swiches to the settingsManager: if args['colour-mode']: settings.set('colourmode', args['colour-mode']) # get ourselves a database manager dbman = DBManager(path=args['mailindex-path'], ro=args['read-only']) # determine what to do try: if args.subCommand == 'search': query = ' '.join(args.subOptions.args) cmdstring = 'search %s %s' % (args.subOptions.as_argparse_opts(), query) cmd = commands.commandfactory(cmdstring, 'global') elif args.subCommand == 'compose': cmdstring = 'compose %s' % args.subOptions.as_argparse_opts() cmd = commands.commandfactory(cmdstring, 'global') else: default_commandline = settings.get('initial_command') cmd = commands.commandfactory(default_commandline, 'global') except CommandParseError, e: sys.exit(e) # set up and start interface UI(dbman, cmd)
def test_create_save_attachment_command_with_arguments(self): cmd = commands.commandfactory('save --all /foo', mode='thread') self.assertIsInstance(cmd, thread.SaveAttachmentCommand) self.assertTrue(cmd.all) self.assertEqual(cmd.path, u'/foo')
logfilename = os.path.expanduser(args['logfile']) logging.basicConfig(level=numeric_loglevel, filename=logfilename) logger = logging.getLogger() #logger.debug(commands.COMMANDS) #accountman aman = AccountManager(settings.config) # get ourselves a database manager dbman = DBManager(path=args['mailindex-path'], ro=args['read-only']) # get initial searchstring try: if args.subCommand == 'search': query = ' '.join(args.subOptions.args) cmd = commands.commandfactory('search ' + query, 'global') elif args.subCommand == 'compose': cmdstring = 'compose %s' % args.subOptions.as_argparse_opts() cmd = commands.commandfactory(cmdstring, 'global') else: default_commandline = settings.config.get('general', 'initial_command') cmd = commands.commandfactory(default_commandline, 'global') except CommandParseError, e: sys.exit(e) # set up and start interface UI(dbman, logger, aman, cmd,