(self, args)
return self.dbfilename, inits, sqls
Process command line options specified in args.  It is safe to
        call this multiple times.  We try to be compatible with SQLite shell
        argument parsing.

        :param args: A list of string options.  Do not include the
           program as args[0]

        :returns: A tuple of (databasefilename, initfiles,
           sqlncommands).  This is provided for informational purposes
           only - they have already been acted upon.  An example use
           is that the SQLite shell does not enter the main interactive
           loop if any sql/commands were provided.

        The first non-option is the database file name.  Each
        remaining non-option is treated as a complete input (ie it
        isn't joined with others looking for a trailing semi-colon).

        The SQLite shell uses single dash in front of options.  We
        allow both single and double dashes.  When an unrecognized
        argument is encountered then
        :meth:`process_unknown_args` is called.
Process command line options specified in args.  It is safe to
        call this multiple times.  We try to be compatible with SQLite shell
        argument parsing.
Process command line options specified in args . It is safe to call this multiple times . We try to be compatible with SQLite shell argument parsing .
def process_args(self, args):
        """Process command line options specified in args.  It is safe to
        call this multiple times.  We try to be compatible with SQLite shell
        argument parsing.

        :param args: A list of string options.  Do not include the
           program as args[0]

        :returns: A tuple of (databasefilename, initfiles,
           sqlncommands).  This is provided for informational purposes
           only - they have already been acted upon.  An example use
           is that the SQLite shell does not enter the main interactive
           loop if any sql/commands were provided.

        The first non-option is the database file name.  Each
        remaining non-option is treated as a complete input (ie it
        isn't joined with others looking for a trailing semi-colon).

        The SQLite shell uses single dash in front of options.  We
        allow both single and double dashes.  When an unrecognized
        argument is encountered then
        :meth:`process_unknown_args` is called.
        """
        # we don't use optparse as we need to use single dashes for
        # options - all hand parsed
        if not args:
            return None, [], []

        # are options still valid?
        options = True
        # have we seen the database name?
        havedbname = False
        # List of init files to read
        inits = []
        # List of sql/dot commands
        sqls = []

        while args:
            if not options or not args[0].startswith("-"):
                options = False
                if not havedbname:
                    # grab new database
                    self.db = None, args[0]
                    havedbname = True
                else:
                    sqls.append(args[0])
                args = args[1:]
                continue

            # remove initial single or double dash
            args[0] = args[0][1:]
            if args[0].startswith("-"):
                args[0] = args[0][1:]

            if args[0] == "init":
                if len(args) < 2:
                    raise self.Error("You need to specify a filename after -init")
                inits.append(args[1])
                args = args[2:]
                continue

            if args[0] == "header" or args[0] == "noheader":
                self.header = args[0] == "header"
                args = args[1:]
                continue

            if args[0] in ("echo", "bail", "interactive"):
                setattr(self, args[0], True)
                args = args[1:]
                continue

            if args[0] == "batch":
                self.interactive = False
                args = args[1:]
                continue

            if args[0] in ("separator", "nullvalue", "encoding"):
                if len(args) < 2:
                    raise self.Error("You need to specify a value after -" + args[0])
                getattr(self, "command_" + args[0])([args[1]])
                args = args[2:]
                continue

            if args[0] == "version":
                self.write(self.stdout, apsw.sqlitelibversion() + "\n")
                # A pretty gnarly thing to do
                sys.exit(0)

            if args[0] == "help":
                self.write(self.stderr, self.usage())
                sys.exit(0)

            if args[0] in ("no-colour", "no-color", "nocolour", "nocolor"):
                self.colour_scheme = "off"
                self._out_colour()
                args = args[1:]
                continue

            # only remaining known args are output modes
            if getattr(self, "output_" + args[0], None):
                self.command_mode(args[:1])
                args = args[1:]
                continue

            newargs = self.process_unknown_args(args)
            if newargs is None:
                raise self.Error("Unrecognized argument '" + args[0] + "'")
            args = newargs

        for f in inits:
            self.command_read([f])

        for s in sqls:
            self.process_complete_line(s)

        return self.dbfilename, inits, sqls
def process_args ( self , args ) : # we don't use optparse as we need to use single dashes for # options - all hand parsed if not args : return None , [ ] , [ ] # are options still valid? options = True # have we seen the database name? havedbname = False # List of init files to read inits = [ ] # List of sql/dot commands sqls = [ ] while args : if not options or not args [ 0 ] . startswith ( "-" ) : options = False if not havedbname : # grab new database self . db = None , args [ 0 ] havedbname = True else : sqls . append ( args [ 0 ] ) args = args [ 1 : ] continue # remove initial single or double dash args [ 0 ] = args [ 0 ] [ 1 : ] if args [ 0 ] . startswith ( "-" ) : args [ 0 ] = args [ 0 ] [ 1 : ] if args [ 0 ] == "init" : if len ( args ) < 2 : raise self . Error ( "You need to specify a filename after -init" ) inits . append ( args [ 1 ] ) args = args [ 2 : ] continue if args [ 0 ] == "header" or args [ 0 ] == "noheader" : self . header = args [ 0 ] == "header" args = args [ 1 : ] continue if args [ 0 ] in ( "echo" , "bail" , "interactive" ) : setattr ( self , args [ 0 ] , True ) args = args [ 1 : ] continue if args [ 0 ] == "batch" : self . interactive = False args = args [ 1 : ] continue if args [ 0 ] in ( "separator" , "nullvalue" , "encoding" ) : if len ( args ) < 2 : raise self . Error ( "You need to specify a value after -" + args [ 0 ] ) getattr ( self , "command_" + args [ 0 ] ) ( [ args [ 1 ] ] ) args = args [ 2 : ] continue if args [ 0 ] == "version" : self . write ( self . stdout , apsw . sqlitelibversion ( ) + "\n" ) # A pretty gnarly thing to do sys . exit ( 0 ) if args [ 0 ] == "help" : self . write ( self . stderr , self . usage ( ) ) sys . exit ( 0 ) if args [ 0 ] in ( "no-colour" , "no-color" , "nocolour" , "nocolor" ) : self . colour_scheme = "off" self . _out_colour ( ) args = args [ 1 : ] continue # only remaining known args are output modes if getattr ( self , "output_" + args [ 0 ] , None ) : self . command_mode ( args [ : 1 ] ) args = args [ 1 : ] continue newargs = self . process_unknown_args ( args ) if newargs is None : raise self . Error ( "Unrecognized argument '" + args [ 0 ] + "'" ) args = newargs for f in inits : self . command_read ( [ f ] ) for s in sqls : self . process_complete_line ( s ) return self . dbfilename , inits , sqls