def setup_parser(parser, completions=False): from rez.shells import get_shell_types from rez.system import system formats = get_shell_types() + ['dict', 'table'] parser.add_argument( "-f", "--format", type=str, choices=formats, help="print output in the given format. If None, the current shell " "language (%s) is used" % system.shell) parser.add_argument( "--no-env", dest="no_env", action="store_true", help="interpret the code in an empty environment") pv_action = parser.add_argument( "--pv", "--parent-variables", dest="parent_vars", type=str, metavar='VAR', nargs='+', help="environment variables to update rather than overwrite on first " "reference. If this is set to the special value 'all', all variables " "will be treated this way") FILE_action = parser.add_argument( "FILE", type=str, help='file containing rex code to execute') if completions: from rez.cli._complete_util import FilesCompleter from rez.vendor.argcomplete.completers import EnvironCompleter pv_action.completer = EnvironCompleter FILE_action.completer = FilesCompleter(dirs=False, file_patterns=["*.py", "*.rex"])
def setup_parser(parser, completions=False): FILE_action = parser.add_argument("FILE", type=str, nargs='*', help="context files") if completions: from rez.cli._complete_util import FilesCompleter FILE_action.completer = FilesCompleter()
def setup_parser(parser, completions=False): file_action = parser.add_argument("FILE", type=str, nargs='?', help='python script to execute') if completions: from rez.cli._complete_util import FilesCompleter file_action.completer = FilesCompleter(dirs=False, file_patterns=["*.py"])
def setup_parser(parser, completions=False): parser.add_argument("--diff", nargs=2, metavar=("RXT1", "RXT2"), help="open in diff mode with the given contexts") FILE_action = parser.add_argument("FILE", type=str, nargs='*', help="context files") if completions: from rez.cli._complete_util import FilesCompleter FILE_action.completer = FilesCompleter()
def setup_parser(parser, completions=False): parser.add_argument( "-i", "--interactive", action="store_true", help="inspect interactively after FILE has run") FILE_action = parser.add_argument( "FILE", type=str, nargs='?', help='python script to execute') parser.add_argument( "ARG", type=str, nargs='*', help='arguments to python script') parser.add_argument('-c', help="python code to execute", dest='command') if completions: from rez.cli._complete_util import FilesCompleter FILE_action.completer = FilesCompleter(dirs=False, file_patterns=["*.py"])
def setup_parser(parser, completions=False): from rez.system import system from rez.shells import get_shell_types formats = get_shell_types() + ['dict', 'table'] if json is not None: formats.append('json') output_styles = [e.name for e in OutputStyle] parser.add_argument( "--req", "--print-request", dest="print_request", action="store_true", help="print only the request list (not including implicits)") parser.add_argument("--res", "--print-resolve", dest="print_resolve", action="store_true", help="print only the resolve list") parser.add_argument( "--so", "--source-order", dest="source_order", action="store_true", help="print resolved packages in order they are sorted, rather than " "alphabetical order") parser.add_argument( "--su", "--show-uris", dest="show_uris", action="store_true", help="list resolved package's URIs, rather than the default 'root' " "filepath") parser.add_argument( "-t", "--tools", action="store_true", help="print a list of the executables available in the context") parser.add_argument("--which", type=str, metavar="CMD", help="locate a program within the context") parser.add_argument("-g", "--graph", action="store_true", help="display the resolve graph as an image") parser.add_argument("--pg", "--print-graph", dest="print_graph", action="store_true", help="print the resolve graph as a string") parser.add_argument("--wg", "--write-graph", dest="write_graph", type=str, metavar='FILE', help="write the resolve graph to FILE") parser.add_argument("--pp", "--prune-package", dest="prune_pkg", metavar="PKG", type=str, help="prune the graph down to PKG") parser.add_argument( "-i", "--interpret", action="store_true", help="interpret the context and print the resulting code") parser.add_argument( "-f", "--format", type=str, choices=formats, default=system.shell, help="print interpreted output in the given format. Ignored if " "--interpret is not present (default: %(default)s). If one of " "table, dict or json, the environ dict is printed.") parser.add_argument( "-s", "--style", type=str, default="file", choices=output_styles, help="Set code output style. Ignored if --interpret is not present " "(default: %(default)s)") parser.add_argument("--no-env", dest="no_env", action="store_true", help="interpret the context in an empty environment") diff_action = parser.add_argument( "--diff", type=str, metavar="RXT", help="diff the current context against the given context") parser.add_argument( "--fetch", action="store_true", help="diff the current context against a re-resolved copy of the " "current context") RXT_action = parser.add_argument( "RXT", type=str, nargs='?', help="rez context file (current context if not supplied). Use '-' to " "read the context from stdin") if completions: from rez.cli._complete_util import FilesCompleter rxt_completer = FilesCompleter(dirs=False, file_patterns=["*.rxt"]) RXT_action.completer = rxt_completer diff_action.completer = rxt_completer
def setup_parser(parser, completions=False): from argparse import SUPPRESS from rez.config import config from rez.system import system from rez.shells import get_shell_types shells = get_shell_types() parser.add_argument( "--shell", dest="shell", type=str, choices=shells, default=config.default_shell or system.shell, help="target shell type (default: %(default)s)") parser.add_argument( "--isolated", action="store_true", help="Do not inherit the parent environment") parser.add_argument( "--inherited", action="store_true", help="Inherit the parent environment") parser.add_argument( "--rcfile", type=str, help="source this file instead of the target shell's standard startup " "scripts, if possible") parser.add_argument( "--norc", action="store_true", help="skip loading of startup scripts") command_action = parser.add_argument( "-c", "--command", type=str, help="read commands from string. Alternatively, list command arguments " "after a '--'") parser.add_argument( "-s", "--stdin", action="store_true", help="read commands from standard input") parser.add_argument( "--ni", "--no-implicit", dest="no_implicit", action="store_true", help="don't add implicit packages to the request") parser.add_argument( "--nl", "--no-local", dest="no_local", action="store_true", help="don't load local packages") parser.add_argument( "-b", "--build", action="store_true", help="create a build environment") parser.add_argument( "--paths", type=str, default=None, help="set package search path") parser.add_argument( "-t", "--time", type=str, help="ignore packages released after the given time. Supported formats " "are: epoch time (eg 1393014494), or relative time (eg -10s, -5m, " "-0.5h, -10d)") parser.add_argument( "--max-fails", type=int, default=-1, dest="max_fails", metavar='N', help="abort if the number of failed configuration attempts exceeds N") parser.add_argument( "--time-limit", type=int, default=-1, dest="time_limit", metavar='SECS', help="abort if the resolve time exceeds SECS") parser.add_argument( "-o", "--output", type=str, metavar="FILE", help="store the context into an rxt file, instead of starting an " "interactive shell. Note that this will also store a failed resolve. " "If you use the special value '-', the context is written to stdout.") input_action = parser.add_argument( "-i", "--input", type=str, metavar="FILE", help="use a previously saved context. Resolve settings, such as PKG, " "--ni etc are ignored in this case") parser.add_argument( "--exclude", type=str, nargs='+', metavar="RULE", help="add package exclusion filters, eg '*.beta'. Note that these are " "added to the globally configured exclusions") parser.add_argument( "-e", "--env", action='append', metavar="KEY=VALUE", help="inject a KEY=VALUE pair into the resulting context. " "Keeps reading key=value pairs until the next argument is passed") parser.add_argument( "--include", type=str, nargs='+', metavar="RULE", help="add package inclusion filters, eg 'mypkg', 'boost-*'. Note that " "these are added to the globally configured inclusions") parser.add_argument( "--no-filters", dest="no_filters", action="store_true", help="turn off package filters. Note that any filters specified with " "--exclude/--include are still applied") parser.add_argument( "-p", "--patch", action="store_true", help="patch the current context to create a new context") parser.add_argument( "--strict", action="store_true", help="strict patching. Ignored if --patch is not present") parser.add_argument( "--patch-rank", type=int, metavar="N", default=0, help="patch rank. Ignored if --patch is not present") parser.add_argument( "--no-cache", dest="no_cache", action="store_true", help="do not fetch cached resolves") parser.add_argument( "-q", "--quiet", action="store_true", help="run in quiet mode (hides welcome message)") parser.add_argument( "--fail-graph", action="store_true", help="if the build environment fails to resolve due to a conflict, " "display the resolve graph as an image.") parser.add_argument( "--new-session", action="store_true", help="start the shell in a new process group") parser.add_argument( "--detached", action="store_true", help="open a separate terminal") parser.add_argument( "--no-passive", action="store_true", help="only print actions that affect the solve (has an effect only " "when verbosity is enabled)") parser.add_argument( "--self", action="store_true", help=( "Include requirement for the version of bleeding-rez " "that's being called, useful for gaining access to " "rez commands from within a rez context.")) parser.add_argument( "--stats", action="store_true", help="print advanced solver stats") parser.add_argument( "--pre-command", type=str, help=SUPPRESS) PKG_action = parser.add_argument( "PKG", type=str, nargs='*', help='packages to use in the target environment') extra_0_action = parser.add_argument( # args after -- "--N0", dest="extra_0", nargs='*', help=SUPPRESS) if completions: from rez.cli._complete_util import PackageCompleter, FilesCompleter, \ ExecutablesCompleter, AndCompleter, SequencedCompleter command_action.completer = AndCompleter(ExecutablesCompleter, FilesCompleter()) input_action.completer = FilesCompleter(dirs=False, file_patterns=["*.rxt"]) PKG_action.completer = PackageCompleter extra_0_action.completer = SequencedCompleter( "extra_0", ExecutablesCompleter, FilesCompleter())
def setup_parser(parser, completions=False): parser.add_argument("-l", "--list", action="store_true", help="list visible suites") parser.add_argument( "-t", "--tools", dest="print_tools", action="store_true", help="print a list of the executables available in the suite") parser.add_argument( "--which", type=str, metavar="TOOL", help="print path to the tool in the suite, if it exists") parser.add_argument("--validate", action="store_true", help="validate the suite") parser.add_argument("--create", action="store_true", help="create an empty suite at DIR") parser.add_argument( "-c", "--context", type=str, metavar="NAME", help="specify a context name (only used when using a context-specific " "option, such as --add)") parser.add_argument("-i", "--interactive", action="store_true", help="enter an interactive shell in the given context") add_action = parser.add_argument("-a", "--add", type=str, metavar="RXT", help="add a context to the suite") parser.add_argument("-r", "--remove", type=str, metavar="NAME", help="remove a context from the suite") parser.add_argument("-d", "--description", type=str, metavar="DESC", help="set the description of a context in the suite") parser.add_argument("-p", "--prefix", type=str, help="set the prefix of a context in the suite") parser.add_argument("-s", "--suffix", type=str, help="set the suffix of a context in the suite") parser.add_argument("--hide", type=str, metavar="TOOL", help="hide a tool of a context in the suite") parser.add_argument("--unhide", type=str, metavar="TOOL", help="unhide a tool of a context in the suite") parser.add_argument("--alias", type=str, nargs=2, metavar=("TOOL", "ALIAS"), help="create an alias for a tool in the suite") parser.add_argument("--unalias", type=str, metavar="TOOL", help="remove an alias for a tool in the suite") parser.add_argument( "-b", "--bump", type=str, metavar="NAME", help="bump a context, making its tools higher priority than others") find_request_action = parser.add_argument( "--find-request", type=str, metavar="PKG", help="find the contexts that contain the given package in the request") find_resolve_action = parser.add_argument( "--find-resolve", type=str, metavar="PKG", help="find the contexts that contain the given package in the resolve") DIR_action = parser.add_argument( "DIR", type=str, nargs='?', help="directory of suite to create or manage") if completions: from rez.cli._complete_util import FilesCompleter, PackageCompleter, \ PackageFamilyCompleter DIR_action.completer = FilesCompleter(dirs=True, files=False) add_action.completer = FilesCompleter(dirs=False, file_patterns=["*.rxt"]) find_request_action.completer = PackageFamilyCompleter find_resolve_action.completer = PackageCompleter
def setup_parser(parser, completions=False): parser.add_argument( "-l", "--list", action="store_true", help="list visible suites") parser.add_argument( "-t", "--tools", dest="print_tools", action="store_true", help="print a list of the executables available in the suite") parser.add_argument( "--which", type=str, metavar="TOOL", help="print path to the tool in the suite, if it exists") parser.add_argument( "--validate", action="store_true", help="validate the suite") parser.add_argument( "--create", action="store_true", help="create an empty suite at DIR") parser.add_argument( "-c", "--context", type=str, metavar="NAME", help="specify a context name (only used when using a context-specific " "option, such as --add)") parser.add_argument( "-i", "--interactive", action="store_true", help="enter an interactive shell in the given context") add_action = parser.add_argument( "-a", "--add", type=str, metavar="RXT", help="add a context to the suite") add_action = parser.add_argument( "-P", "--prefix-char", dest="prefix_char", type=str, metavar="CHAR", help="set the char used to access rez options via a suite tool " "for the context being added (default: '+'). If set to the empty string, " "rez options are disabled. This option is only used in combination with " "--add") parser.add_argument( "-r", "--remove", type=str, metavar="NAME", help="remove a context from the suite") parser.add_argument( "-d", "--description", type=str, metavar="DESC", help="set the description of a context in the suite") parser.add_argument( "-p", "--prefix", type=str, help="set the prefix of a context in the suite") parser.add_argument( "-s", "--suffix", type=str, help="set the suffix of a context in the suite") parser.add_argument( "--hide", type=str, metavar="TOOL", help="hide a tool of a context in the suite") parser.add_argument( "--unhide", type=str, metavar="TOOL", help="unhide a tool of a context in the suite") parser.add_argument( "--alias", type=str, nargs=2, metavar=("TOOL", "ALIAS"), help="create an alias for a tool in the suite") parser.add_argument( "--unalias", type=str, metavar="TOOL", help="remove an alias for a tool in the suite") parser.add_argument( "--reresolve", action='store_true', dest='re_resolve', default=None) parser.add_argument( "--no-reresolve", action='store_false', dest='re_resolve', default=None, help="Re-resolve before running tools from this context " "(will not re-resolve by default for new packages)") parser.add_argument( "-b", "--bump", type=str, metavar="NAME", help="bump a context, making its tools higher priority than others") find_request_action = parser.add_argument( "--find-request", type=str, metavar="PKG", help="find the contexts that contain the given package in the request") find_resolve_action = parser.add_argument( "--find-resolve", type=str, metavar="PKG", help="find the contexts that contain the given package in the resolve") DIR_action = parser.add_argument( "DIR", type=str, nargs='?', help="directory of suite to create or manage") if completions: from rez.cli._complete_util import FilesCompleter, PackageCompleter, \ PackageFamilyCompleter DIR_action.completer = FilesCompleter(dirs=True, files=False) add_action.completer = FilesCompleter(dirs=False, file_patterns=["*.rxt"]) find_request_action.completer = PackageFamilyCompleter find_resolve_action.completer = PackageCompleter