def get_cli_options(self): '''get command line options & return OptionParser''' parser = OptionParser() parser.add_option("-r", "--resultsfile", dest="resultsfile") parser.add_option("-f", "--runfile", dest="runfile", help="filename to save results") parser.add_option("--log", dest="loglevel", help="Logging level", default='ERROR') opts, args = parser.parse_args() # set object attributes to CLI args for opt in [x.dest for x in parser._get_all_options()[1:]]: if getattr(opts, opt) is not None: self.options[opt] = getattr(opts, opt)
def base_09_options(): # Setup argument parser parser = OptionParser() parser._get_all_options() parser.add_option( '-M', '--dependency_file', dest='dependency_file', help='optional multi-component dependency resolution file') parser.add_option( '-b', '--build-script', dest='build_script', help= 'optional custom build tool launcher script (defaults to <project>/cfg/build.py if present, otherwise vmake' ) parser.add_option('-n', '--alternate-path', dest='alternate_path', help='optional give alternate path to discover plugin') parser.add_option( '-B', '--skip-build-phase', dest='skip_build', action='store_true', help="skip the execution of the build plugin's build step") parser.add_option( '-c', '--clean-build', dest='do_clean', action='store_true', help='perform a "clean" build (eradicate any previous build results)') parser.add_option( '-s', '--purge-all', dest='do_purge_all', action='store_true', help= 'eradicate ALL previous build cfg and start build anew, only applying args from current command line' ) parser.add_option( "-r", "--project-root-dir", dest="project_root_dir", help="project root directory (default is configured from .xmake file)") parser.add_option( "-l", "--gendir-label", dest="gendir_label", help="logical name of generation directory [default: 'gen']") parser.add_option( "-g", "--gendir", dest="gendir", help="optional gen dir, [default: <project-root-dir/<label>>]") parser.add_option("-m", "--mode", dest="mode", help="build mode (e.g. dbg, rel, opt)") parser.add_option("-p", "--platform", dest="platform", help="build platform (e.g. ntintel)") parser.add_option( "-I", "--import-repo", dest="import_repos", action='append', help= "maven repository URL to import from. Specify multiple times to have more than repository." ) parser.add_option("-i", '--import', dest="do_import", action='store_true', help="import from configured maven-repos before build") parser.add_option("-E", "--export-repo", dest="export_repos", action='append', help="maven upload repository URL") parser.add_option("-U", "--deploy-user", dest="deploy_users", action='append', help="user name for repository deployment") parser.add_option("-P", "--deploy-password", dest="deploy_passwords", action='append', help="password for repository deployment") parser.add_option( "--deploy-credentials-key", dest="deploy_cred_keys", action='append', help= 'credential key for repository deployment (replaces -U,-P if specified)' ) parser.add_option("-e", "--export", dest="do_export", action='store_true', help="export build results after build") parser.add_option( "-d", "--deploy", dest="do_deploy", action='store_true', help= "deploy exported results to the configured maven repository (implies -e, requires -E)" ) parser.add_option( "-R", "--promote", dest="do_promote", action='store_true', help="promote staged results to the configured maven repository") parser.add_option("-v", "--version", dest="version", help="build result version for build result exposure") parser.add_option("--show-info", dest="show_version", action="store_true", help="show xmake version info") parser.add_option("-X", "--xmake-version", dest="xmake_version", help="dedicated version of xmake used for the build") parser.add_option( "--default-xmake-version", dest="default_xmake_version", help="xmake version to use if no version is specified in sources") parser.add_option( '--scm-snapshot-url', dest="scm_snapshot_url", help= "an unambiguous URL that identifies the source tree this build was based upon" ) parser.add_option( '--productive', dest="productive", action='store_true', help= 'if set, the build behaves as a productive build, applying additional checks (e.g. existence of release metadata)' ) parser.add_option( '--release', dest="release", help= 'if set with direct-shipment or indirect-shipment, the build behaves as a release build, applying additional checks (e.g. existence of release metadata or run MQR plugin)' ) parser.add_option( '--use-current-xmake-version', dest="use_current_xmake_version", action='store_true', help='if set, the build uses the initially called version of xmake)') parser.add_option( '--debug-xmake', dest="debug_xmake", action='store_true', help='provide more internal execution information in log') parser.add_option( '--get-version', dest="get_version", action='store_true', help= 'get project version and make it available in gen/temp/project.version ' ) parser.add_option('--set-version', dest="set_version", help='set the given project version ') parser.add_option('--drop-staging', dest="do_drop_staging", action='store_true', help="drop the given staging repository") parser.add_option( '--staging-repo', dest="staging_repoid", action='store', help="Optional Staging repo ID for staging, closing and promoting") parser.add_option('--create-staging', dest="do_create_staging", action='store_true', help='Create staging repository') parser.add_option('--close-staging', dest="do_close_staging", action='store_true', help='Close staging repository') return parser
for opt,val in hCfg.items(): if type(getattr(opts,opt))!=type('str'): val = eval(val,{},{}) setattr(opts,opt,val) if opts.verbose: printOptions() # set hist attributes here: setAttributes(hist) hists.append([hist,hCfg['draw']]) # passing other options here else: optName = line.split('=')[0] optVal = line.split('=')[1] if optName not in [x.dest for x in parser._get_all_options()[1:]]: print 'Unrecognised option: %s'%optName sys.exit() else: if ',' in optVal: els = optVal.split(',') convEls=[] for el in els: el = eval(el,{},{}) convEls.append(el) setattr(opts,optName,convEls) else: if type(getattr(opts,optName))==type(optVal): setattr(opts,optName,optVal) else: #print type(getattr(opts,optName))