def _print_help(self): """Print a help screen, followed by an optional message. Note: Ony useful if called after options have been registered. """ show_all_help = self._help_request and self._help_request.all_scopes goals = (Goal.all() if show_all_help else [Goal.by_name(goal_name) for goal_name in self.goals]) if goals: for goal in goals: if not goal.ordered_task_names(): print('\nUnknown goal: {}'.format(goal.name)) else: print('\n{0}: {1}\n'.format(goal.name, goal.description)) for scope_info in goal.known_scope_infos(): help_str = self._format_help_for_scope(scope_info.scope) if help_str: print(help_str) else: print(pants_release()) print('\nUsage:') print(' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.') print(' ./pants help Get help.') print(' ./pants help [goal] Get help for a goal.') print(' ./pants help-advanced [goal] Get help for a goal\'s advanced options.') print(' ./pants help-all Get help for all goals.') print(' ./pants goals List all installed goals.') print('') print(' [target] accepts two special forms:') print(' dir: to include all targets in the specified directory.') print(' dir:: to include all targets found recursively under the directory.') print('\nFriendly docs:\n http://pantsbuild.github.io/') if show_all_help or not goals: print(self.get_parser(GLOBAL_SCOPE).format_help('Global', self._help_request.advanced))
def print_help(goals=None): if goals: for goal in goals: goal = Goal.by_name(goal) if not goal.ordered_task_names(): print('\nUnknown goal: %s' % goal) else: parser = OptionParser(add_help_option=False) Goal.setup_parser(parser, [], [goal]) print('\n%s: %s' % (goal.name, goal.description)) _print_flags(parser, goal.name) else: print(pants_release()) print('\nUsage:') print( ' ./pants goal [option ...] [goal ...] [target...] Attempt the specified goals.' ) print(' ./pants goal help Get help.') print( ' ./pants goal help [goal] Get help for the specified goal.' ) print( ' ./pants goal goals List all installed goals.' ) print('') print(' [target] accepts two special forms:') print(' dir: to include all targets in the specified directory.') print( ' dir:: to include all targets found recursively under the directory.' ) print('\nFriendly docs:\n http://pantsbuild.github.io/') _print_global_flags()
def print_help(goals=None): if goals: for goal in goals: phase = Phase(goal) if not phase.goals(): print('\nUnknown goal: %s' % goal) else: parser = OptionParser(add_help_option=False) phase.setup_parser(parser, [], [phase]) print('\n%s: %s' % (phase.name, phase.description)) _print_flags(parser, phase.name) else: print(pants_release()) print('\nUsage:') print(' ./pants goal [option ...] [goal ...] [target...] Attempt the specified goals.') print(' ./pants goal help Get help.') print(' ./pants goal help [goal] Get help for the specified goal.') print(' ./pants goal goals List all installed goals.') print('') print(' [target] accepts two special forms:') print(' dir: to include all targets in the specified directory.') print(' dir:: to include all targets found recursively under the directory.') print('\nFriendly docs:\n http://pantsbuild.github.io/') _print_global_flags()
def _print_options_help(self): """Print a help screen. Assumes that self._help_request is an instance of OptionsHelp. Note: Ony useful if called after options have been registered. """ show_all_help = self._help_request.all_scopes if show_all_help: help_scopes = list(self._options.known_scope_to_info.keys()) else: # The scopes explicitly mentioned by the user on the cmd line. help_scopes = set( self._options.scope_to_flags.keys()) - {GLOBAL_SCOPE} scope_infos = list( ScopeInfoIterator( self._options.known_scope_to_info).iterate(help_scopes)) if scope_infos: for scope_info in scope_infos: help_str = self._format_help(scope_info) if help_str: print(help_str) return else: print(pants_release()) print('\nUsage:') print( f' {self.bin_name} [option ...] [goal ...] [target...] Attempt the specified goals.' ) print( f' {self.bin_name} help Get help.' ) print( f' {self.bin_name} help [goal] Get help for a goal.' ) print( f' {self.bin_name} help-advanced [goal] Get help for a goal\'s advanced options.' ) print( f' {self.bin_name} help-all Get help for all goals.' ) print( f' {self.bin_name} goals List all installed goals.' ) print('') print(' [target] accepts two special forms:') print( ' dir: to include all targets in the specified directory.') print( ' dir:: to include all targets found recursively under the directory.' ) print('\nFriendly docs:\n http://pantsbuild.org/') print(self._format_help(ScopeInfo(GLOBAL_SCOPE, ScopeInfo.GLOBAL)))
def _print_help(self): """Print a help screen, followed by an optional message. Note: Ony useful if called after options have been registered. """ def _maybe_help(scope): s = self._format_help_for_scope(scope) if s != '': # Avoid printing scope name for scope with empty options. print(scope) for line in s.split('\n'): if line != '': # Avoid superfluous blank lines for empty strings. print(' {0}'.format(line)) show_all_help = self._help_request and self._help_request.all_scopes goals = (Goal.all() if show_all_help else [Goal.by_name(goal_name) for goal_name in self.goals]) if goals: for goal in goals: if not goal.ordered_task_names(): print('\nUnknown goal: %s' % goal.name) else: print('\n{0}: {1}\n'.format(goal.name, goal.description)) for scope in goal.known_scopes(): _maybe_help(scope) else: print(pants_release()) print('\nUsage:') print( ' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.' ) print(' ./pants help Get help.') print( ' ./pants help [goal] Get help for a goal.' ) print( ' ./pants help-advanced [goal] Get help for a goal\'s advanced options.' ) print( ' ./pants help-all Get help for all goals.' ) print( ' ./pants goals List all installed goals.' ) print('') print(' [target] accepts two special forms:') print( ' dir: to include all targets in the specified directory.') print( ' dir:: to include all targets found recursively under the directory.' ) print('\nFriendly docs:\n http://pantsbuild.github.io/') if show_all_help or not goals: print('\nGlobal options:') print(self.get_global_parser().format_help())
def _print_options_help(self): """Print a help screen. Assumes that self._help_request is an instance of OptionsHelp. Note: Ony useful if called after options have been registered. """ show_all_help = self._help_request.all_scopes if show_all_help: help_scopes = self._known_scope_to_info.keys() else: # The scopes explicitly mentioned by the user on the cmd line. help_scopes = set(self._options.scope_to_flags.keys()) - set([GLOBAL_SCOPE]) # As a user-friendly heuristic, add all task scopes under requested scopes, so that e.g., # `./pants help compile` will show help for compile.java, compile.scala etc. # Note that we don't do anything similar for subsystems - that would just create noise by # repeating options for every task-specific subsystem instance. for scope, info in self._known_scope_to_info.items(): if info.category == ScopeInfo.TASK: outer = enclosing_scope(scope) while outer != GLOBAL_SCOPE: if outer in help_scopes: help_scopes.add(scope) break outer = enclosing_scope(outer) help_scope_infos = [self._known_scope_to_info[s] for s in sorted(help_scopes)] if help_scope_infos: for scope_info in self._help_subscopes_iter(help_scope_infos): description = (scope_info.optionable_cls.get_description() if scope_info.optionable_cls else None) help_str = self._format_help(scope_info, description) if help_str: print(help_str) return else: print(pants_release()) print('\nUsage:') print(' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.') print(' ./pants help Get help.') print(' ./pants help [goal] Get help for a goal.') print(' ./pants help-advanced [goal] Get help for a goal\'s advanced options.') print(' ./pants help-all Get help for all goals.') print(' ./pants goals List all installed goals.') print('') print(' [target] accepts two special forms:') print(' dir: to include all targets in the specified directory.') print(' dir:: to include all targets found recursively under the directory.') print('\nFriendly docs:\n http://pantsbuild.github.io/') print(self._format_help(ScopeInfo(GLOBAL_SCOPE, ScopeInfo.GLOBAL), ''))
def print_help(self, msg=None, goals=None, legacy=False): """Print a help screen, followed by an optional message. Note: Ony useful if called after options have been registered. """ def _maybe_print(s): if s != '': # Avoid superfluous blank lines for empty strings. print(s) goals = goals or self.goals if goals: for goal_name in goals: goal = Goal.by_name(goal_name) if not goal.ordered_task_names(): print('\nUnknown goal: %s' % goal_name) else: _maybe_print( self.format_help('%s' % goal.name, legacy=legacy)) for task_name in goal.ordered_task_names(): if task_name != goal.name: # Otherwise we registered on the goal scope. scope = '%s.%s' % (goal.name, task_name) _maybe_print(self.format_help(scope, legacy=legacy)) else: print(pants_release()) print('\nUsage:') print( ' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.' ) print(' ./pants help Get help.') print( ' ./pants help [goal] Get help for the specified goal.' ) print( ' ./pants goals List all installed goals.' ) print('') print(' [target] accepts two special forms:') print( ' dir: to include all targets in the specified directory.') print( ' dir:: to include all targets found recursively under the directory.' ) print('\nFriendly docs:\n http://pantsbuild.github.io/') print('\nGlobal options:') print(self.format_global_help()) if msg is not None: print(msg)
def _print_options_help(self): """Print a help screen. Assumes that self._help_request is an instance of OptionsHelp. Note: Ony useful if called after options have been registered. """ show_all_help = self._help_request.all_scopes if show_all_help: help_scopes = self._known_scope_to_info.keys() else: # The scopes explicitly mentioned by the user on the cmd line. help_scopes = set(self._scope_to_flags.keys()) - set([GLOBAL_SCOPE]) # Add all subscopes (e.g., so that `pants help compile` shows help for all tasks under # `compile`.) Note that sorting guarantees that we only need to check the immediate parent. for scope in sorted(self._known_scope_to_info.keys()): if scope.partition('.')[0] in help_scopes: help_scopes.add(scope) help_scope_infos = [self._known_scope_to_info[s] for s in sorted(help_scopes)] if help_scope_infos: for scope_info in help_scope_infos: help_str = self._format_options_help_for_scope(scope_info) if help_str: print(help_str) return else: print(pants_release()) print('\nUsage:') print(' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.') print(' ./pants help Get help.') print(' ./pants help [goal] Get help for a goal.') print(' ./pants help-advanced [goal] Get help for a goal\'s advanced options.') print(' ./pants help-all Get help for all goals.') print(' ./pants goals List all installed goals.') print('') print(' [target] accepts two special forms:') print(' dir: to include all targets in the specified directory.') print(' dir:: to include all targets found recursively under the directory.') print('\nFriendly docs:\n http://pantsbuild.github.io/') print(self.get_parser(GLOBAL_SCOPE).format_help('Global', 'Global options', show_advanced=self._help_request.advanced))
def print_help(self, msg=None, goals=None): """Print a help screen, followed by an optional message. Note: Ony useful if called after options have been registered. """ def _maybe_help(scope): s = self.format_help(scope) if s != '': # Avoid printing scope name for scope with empty options. print(scope) for line in s.split('\n'): if line != '': # Avoid superfluous blank lines for empty strings. print(' {0}'.format(line)) goals = goals or self.goals if goals: for goal_name in goals: goal = Goal.by_name(goal_name) if not goal.ordered_task_names(): print('\nUnknown goal: %s' % goal_name) else: print('\n{0}: {1}\n'.format(goal.name, goal.description)) for scope in goal.known_scopes(): _maybe_help(scope) else: print(pants_release()) print('\nUsage:') print(' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.') print(' ./pants help Get help.') print(' ./pants help [goal] Get help for the specified goal.') print(' ./pants goal goals List all installed goals.') print('') print(' [target] accepts two special forms:') print(' dir: to include all targets in the specified directory.') print(' dir:: to include all targets found recursively under the directory.') print('\nFriendly docs:\n http://pantsbuild.github.io/') print('\nGlobal options:') print(self.format_global_help()) if msg is not None: print(msg)
def _print_help(self): """Print a help screen, followed by an optional message. Note: Ony useful if called after options have been registered. """ def _maybe_help(scope): s = self._format_help_for_scope(scope) if s != '': # Avoid printing scope name for scope with empty options. print(scope) for line in s.split('\n'): if line != '': # Avoid superfluous blank lines for empty strings. print(' {0}'.format(line)) show_all_help = self._help_request and self._help_request.all_scopes goals = (Goal.all() if show_all_help else [Goal.by_name(goal_name) for goal_name in self.goals]) if goals: for goal in goals: if not goal.ordered_task_names(): print('\nUnknown goal: {}'.format(goal.name)) else: print('\n{0}: {1}\n'.format(goal.name, goal.description)) for scope in goal.known_scopes(): _maybe_help(scope) else: print(pants_release()) print('\nUsage:') print(' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.') print(' ./pants help Get help.') print(' ./pants help [goal] Get help for a goal.') print(' ./pants help-advanced [goal] Get help for a goal\'s advanced options.') print(' ./pants help-all Get help for all goals.') print(' ./pants goals List all installed goals.') print('') print(' [target] accepts two special forms:') print(' dir: to include all targets in the specified directory.') print(' dir:: to include all targets found recursively under the directory.') print('\nFriendly docs:\n http://pantsbuild.github.io/') if show_all_help or not goals: print('\nGlobal options:') print(self.get_global_parser().format_help())
def print_help(self, msg=None, goals=None, legacy=False): """Print a help screen, followed by an optional message. Note: Ony useful if called after options have been registered. """ def _maybe_print(s): if s != '': # Avoid superfluous blank lines for empty strings. print(s) goals = goals or self.goals if goals: for goal_name in goals: goal = Goal.by_name(goal_name) if not goal.ordered_task_names(): print('\nUnknown goal: %s' % goal_name) else: _maybe_print(self.format_help('%s' % goal.name, legacy=legacy)) for task_name in goal.ordered_task_names(): if task_name != goal.name: # Otherwise we registered on the goal scope. scope = '%s.%s' % (goal.name, task_name) _maybe_print(self.format_help(scope, legacy=legacy)) else: print(pants_release()) print('\nUsage:') print(' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.') print(' ./pants help Get help.') print(' ./pants help [goal] Get help for the specified goal.') print(' ./pants goals List all installed goals.') print('') print(' [target] accepts two special forms:') print(' dir: to include all targets in the specified directory.') print(' dir:: to include all targets found recursively under the directory.') print('\nFriendly docs:\n http://pantsbuild.github.io/') print('\nGlobal options:') print(self.format_global_help()) if msg is not None: print(msg)
def _print_options_help(self): """Print a help screen. Assumes that self._help_request is an instance of OptionsHelp. Note: Ony useful if called after options have been registered. """ show_all_help = self._help_request.all_scopes if show_all_help: help_scopes = self._options.known_scope_to_info.keys() else: # The scopes explicitly mentioned by the user on the cmd line. help_scopes = set(self._options.scope_to_flags.keys()) - set([GLOBAL_SCOPE]) scope_infos = list(ScopeInfoIterator(self._options.known_scope_to_info).iterate(help_scopes)) if scope_infos: for scope_info in scope_infos: help_str = self._format_help(scope_info) if help_str: print(help_str) return else: print(pants_release()) print("\nUsage:") print(" ./pants [option ...] [goal ...] [target...] Attempt the specified goals.") print(" ./pants help Get help.") print(" ./pants help [goal] Get help for a goal.") print(" ./pants help-advanced [goal] Get help for a goal's advanced options.") print(" ./pants help-all Get help for all goals.") print(" ./pants goals List all installed goals.") print("") print(" [target] accepts two special forms:") print(" dir: to include all targets in the specified directory.") print(" dir:: to include all targets found recursively under the directory.") print("\nFriendly docs:\n http://pantsbuild.org/") print(self._format_help(ScopeInfo(GLOBAL_SCOPE, ScopeInfo.GLOBAL)))
def _print_options_help(self) -> None: """Print a help screen. Assumes that self._help_request is an instance of OptionsHelp. Note: Ony useful if called after options have been registered. """ help_request = cast(OptionsHelp, self._help_request) global_options = self._options.for_global_scope() if help_request.all_scopes: help_scopes = set(self._options.known_scope_to_info.keys()) else: # The scopes explicitly mentioned by the user on the cmd line. help_scopes = set( self._options.scope_to_flags.keys()) - {GLOBAL_SCOPE} # If --v1 is enabled at all, don't use v2_help, even if --v2 is also enabled. v2_help = global_options.v2 and not global_options.v1 scope_info_iterator = ScopeInfoIterator( scope_to_info=self._options.known_scope_to_info, v2_help=v2_help) scope_infos = list(scope_info_iterator.iterate(help_scopes)) if scope_infos: for scope_info in scope_infos: help_str = self._format_help(scope_info, help_request.advanced) if help_str: print(help_str) return else: print(pants_release()) print("\nUsage:") print( f" {self.bin_name} [option ...] [goal ...] [target/file ...] Attempt the specified goals." ) print( f" {self.bin_name} help Get help." ) print( f" {self.bin_name} help [goal] Get help for a goal." ) print( f" {self.bin_name} help-advanced Get help for global advanced options." ) print( f" {self.bin_name} help-advanced [goal] Get help for a goal's advanced options." ) print( f" {self.bin_name} help-all Get help for all goals." ) print( f" {self.bin_name} goals List all installed goals." ) print("") print(" [file] can be:") print(" A path to a file.") print( " A path glob, such as '**/*.ext', in quotes to prevent shell expansion." ) print(" [target] accepts two special forms:") print( " dir: to include all targets in the specified directory.") print( " dir:: to include all targets found recursively under the directory." ) print("\nFriendly docs:\n http://pantsbuild.org/") print( self._format_help(ScopeInfo(GLOBAL_SCOPE, ScopeInfo.GLOBAL), help_request.advanced))
def _print_options_help(self): """Print a help screen. Assumes that self._help_request is an instance of OptionsHelp. Note: Ony useful if called after options have been registered. """ show_all_help = self._help_request.all_scopes if show_all_help: help_scopes = self._known_scope_to_info.keys() else: # The scopes explicitly mentioned by the user on the cmd line. help_scopes = set(self._scope_to_flags.keys()) - set( [GLOBAL_SCOPE]) # Add all subscopes (e.g., so that `pants help compile` shows help for all tasks under # `compile`.) Note that sorting guarantees that we only need to check the immediate parent. for scope in sorted(self._known_scope_to_info.keys()): if scope.partition('.')[0] in help_scopes: help_scopes.add(scope) help_scope_infos = [ self._known_scope_to_info[s] for s in sorted(help_scopes) ] if help_scope_infos: for scope_info in help_scope_infos: help_str = self._format_options_help_for_scope(scope_info) if help_str: print(help_str) return else: print(pants_release()) print('\nUsage:') print( ' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.' ) print(' ./pants help Get help.') print( ' ./pants help [goal] Get help for a goal.' ) print( ' ./pants help-advanced [goal] Get help for a goal\'s advanced options.' ) print( ' ./pants help-all Get help for all goals.' ) print( ' ./pants goals List all installed goals.' ) print('') print(' [target] accepts two special forms:') print( ' dir: to include all targets in the specified directory.') print( ' dir:: to include all targets found recursively under the directory.' ) print('\nFriendly docs:\n http://pantsbuild.github.io/') print( self.get_parser(GLOBAL_SCOPE).format_help( 'Global', 'Global options', show_advanced=self._help_request.advanced))
def _print_options_help(self): """Print a help screen. Assumes that self._help_request is an instance of OptionsHelp. Note: Ony useful if called after options have been registered. """ show_all_help = self._help_request.all_scopes if show_all_help: help_scopes = self._known_scope_to_info.keys() else: # The scopes explicitly mentioned by the user on the cmd line. help_scopes = set(self._options.scope_to_flags.keys()) - set( [GLOBAL_SCOPE]) # As a user-friendly heuristic, add all task scopes under requested scopes, so that e.g., # `./pants help compile` will show help for compile.java, compile.scala etc. # Note that we don't do anything similar for subsystems - that would just create noise by # repeating options for every task-specific subsystem instance. for scope, info in self._known_scope_to_info.items(): if info.category == ScopeInfo.TASK: outer = enclosing_scope(scope) while outer != GLOBAL_SCOPE: if outer in help_scopes: help_scopes.add(scope) break outer = enclosing_scope(outer) help_scope_infos = [ self._known_scope_to_info[s] for s in sorted(help_scopes) ] if help_scope_infos: for scope_info in self._help_subscopes_iter(help_scope_infos): description = (scope_info.optionable_cls.get_description() if scope_info.optionable_cls else None) help_str = self._format_help(scope_info, description) if help_str: print(help_str) return else: print(pants_release()) print('\nUsage:') print( ' ./pants [option ...] [goal ...] [target...] Attempt the specified goals.' ) print(' ./pants help Get help.') print( ' ./pants help [goal] Get help for a goal.' ) print( ' ./pants help-advanced [goal] Get help for a goal\'s advanced options.' ) print( ' ./pants help-all Get help for all goals.' ) print( ' ./pants goals List all installed goals.' ) print('') print(' [target] accepts two special forms:') print( ' dir: to include all targets in the specified directory.') print( ' dir:: to include all targets found recursively under the directory.' ) print('\nFriendly docs:\n http://pantsbuild.github.io/') print( self._format_help(ScopeInfo(GLOBAL_SCOPE, ScopeInfo.GLOBAL), ''))