def _show_existing_tasks(self): """ A function to display existing tasks. """ warn('No tasks specified. Available tasks are:', None) out() self._module_set.print_available_tasks() self._rc = 1
def test_out_ignore_quiet(self): with Options(quiet=True): with FakeEcho.simple('test') as fe: out('test', respect_quiet=False) assert fe.was_called() with FakeEcho.simple('test') as fe: out('test', respect_quiet=False) assert fe.was_called()
def _execute_tasks(self, tasks: Sequence[Tuple[Language, Task]]): """ A function that executes the given list of tasks. We note each task is "visited" but (obviously) only execute those for which a function exists. :param tasks: a sequence of module/task pairs to execute. """ for module, task in tasks: out(f'--> {task.name}', fg='bright_green') if task.function is not None: self._execute_task(module, task)
def cli(quiet, verbose, directory, language, no_requires, force_fetch, set_var, tasks): """ Use this tool to build things based on a language. Each language has its own toolchain and associated tasks. Describe a project in a "project.yaml" file at the root of your project. """ # First, we need to store our global options. global_options.\ set_quiet(quiet).\ set_verbose(verbose).\ set_languages(language).\ set_independent_tasks(no_requires).\ set_force_remote_fetch(force_fetch).\ set_vars(set_var).\ set_tasks(tasks) project = get_project(Path(directory) if directory else Path.cwd()) if project.has_no_languages(): end('No language(s) specified in project.yaml or with --language option.' ) if project.has_unknown_languages(): unsupported = ', '.join(project.get_unknown_languages()) end(f'Unsupported language(s) specified in project.yaml/--language: {unsupported}' ) # Make the project globally known. global_options.set_project(project) out(f'Project: {project.description}', fg='bright_white') try: sys.exit(Engine(project).run()) except ValueError as error: end(error.args[0])
def check_dependency_versions(): """ A function that provides the implementation of the ``check-versions`` task for the Java language. It will attempt to verify the version of all dependencies noted in the current project and report when a dependency is not using the current one or it's version cannot be found. """ context = global_options.project().get_full_dependency_context('java') local_paths = global_options.project().configuration.local_paths for dependency in context.dependencies: resolver, _, _ = build_names(dependency, version_in_url=False) version_info = None context.set_remote_resolver(resolver) if dependency.is_remote: version_info = _get_remote_version_info(context, dependency) elif dependency.is_project: publishing_directory = context.get_publishing_directory( dependency.key) if publishing_directory: version_info = _get_local_version_info([publishing_directory], dependency.name) else: # dependency.is_local version_info = _get_local_version_info(local_paths, dependency.name) if version_info: dependency_version = Version(dependency.version) latest, available = version_info if latest == dependency_version: out(f' - {dependency.name}: {dependency_version} (current).') elif dependency_version not in available: out(f' - Version {dependency.version} of {dependency.name} is not available.' ) else: out(f' - {dependency.name}: {dependency_version} (not latest; latest is {latest}).' ) else: out(f' - Could not obtain version information for the {dependency.name} dependency.' )
def print_available_tasks(self): """ A function that prints out the list of tasks that are defined in each of our known modules. """ for module_name, module in self._modules.items(): out(f' {module_name}', respect_quiet=False, fg='white') name_width = max(len(task.name) for task in module.tasks) for task in module.tasks: task_name = click.style(f'{task.name.ljust(name_width)}', fg='bright_green') task_help = click.style(f'{task.help_text}', fg='green') out(f' {task_name} -- {task_help}', respect_quiet=False) out('', respect_quiet=False)
def test_out_quiet(self): with Options(quiet=True): with FakeEcho.simple('test') as fe: out('test') assert not fe.was_called()
def test_out_with_kwargs(self): with FakeEcho.simple('test', fg='white') as fe: out('test', fg='white') assert fe.was_called()
def test_simple_out(self): with FakeEcho.simple('test') as fe: out('test') assert fe.was_called()