def cli():
    """Command-line interface.  Call this without any options for usage notes."""
    import getopt
    
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'haixbcm:n:', ['help',
                                                                'analyze',
                                                                'initialize',
                                                                'ccube',
                                                                'cmap',
                                                                'sourcemap',
                                                                'modelmap',
                                                                'modelcube',
                                                                'ccube',
                                                                'bexpmap',
                                                                'filter',
                                                                'xml',
                                                                'binsize'
                                                                ])
        #Loop through first and check for the basename
        haveBase = False
        basename = 'example'
        for opt,val in opts:
            if opt in ('-n','--basename'):
                haveBase = True
                basename = val

        for opt, val in opts:
            if opt in ('-h', '--help'):
                printCLIHelp()
                return
            elif opt in ('-a', '--analyze'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                qA = quickAnalysis(basename, True)
                qA.runAll(True)         
                return
            elif opt in ('-i', '--initialize'):
                print "Creating example configuration file called example.cfg"
                qA = quickAnalysis(basename)
                qA.writeConfig()
                return
            elif opt in ('--modelmap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating model map"
                qA = quickAnalysis(basename, True)
                for option,value in opts:
                    if option in ('-m'):
                        modelFile = value
                    else:
                        modelFile = ''
                qU.runModelMap(qA.logger,qA.commonConf['base'],modelFile,qA.commonConf['irfs'],False)
                return
            elif opt in ('--modelcube'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating model cube"
                qA = quickAnalysis(basename, True)
                for option,value in opts:
                    if option in ('-m'):
                        modelFile = value
                    else:
                        modelFile = ''
                qU.runModelMap(qA.logger,qA.commonConf['base'],modelFile,qA.commonConf['irfs'],True)
                return
            elif opt in ('--sourcemap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating source map"
                qA = quickAnalysis(basename, True)
                qA.runSrcMaps()
                return
            elif opt in ('--ccube'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating counts cube"
                qA = quickAnalysis(basename, True)
                qA.runCCUBE()
                return
            elif opt in ('--bexpmap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating binned exposure map"
                qA = quickAnalysis(basename, True)
                qA.runExpCube()
                return
            elif opt in ('--filter'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating filtered (selected and GTI'd) file"
                qA = quickAnalysis(basename, True)
                qA.runSelect()
                qA.runGTI()
                return
            elif opt in ('-x', '--xml'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating XML model file from 2FGL"
                qA = quickAnalysis(basename, True)
                qA.generateXMLmodel()
                return
            elif opt in ('-c', '--cmap'):
                if not haveBase: raise getopt.GetoptError("Must specify basename, printing help.")
                print "Creating counts map"
                qA = quickAnalysis(basename, True)
                for option,value in opts:
                    if option in ('-b', '--binsize'): qA.analysisConf['binsize'] = value
                qA.runCMAP()
                return
                
        if not opts: raise getopt.GetoptError("Must specify an option, printing help.")

    except getopt.error as e:
        print "Command Line Error: " + e.msg
        printCLIHelp()
    def runModelMap(self, run=True):

        """Wrapper for the same function in quickUtils"""

        qU.runModelMap(self.logger,self.commonConf['base'],'',self.commonConf['irfs'],False,run)