 '{action!s}'".
                format(action=action),
            )

        # OK, now we know that the action is valid and we have the
        # right number of words on the line for that action -- so we
        # can proceed with minimal error-checking.

        action_is_recursive = action.startswith('recursive-')
        if action in {'graft', 'prune'}:
            patterns = [dir_pattern]
        extra_log_args = (dir, ) if action_is_recursive else ()
        log_tmpl = log_map[action]

        self.debug_print(
            ' '.join(
                [action] +
                ([dir] if action_is_recursive else []) +
                patterns,
            )
        )
        for pattern in patterns:
            if not process_action(pattern):
                log.warn(log_tmpl, pattern, *extra_log_args)

    def _remove_files(self, predicate):
        """
        Remove all files from the file list that match the predicate.
        Return True if any matching files were removed
        """
        found = False
        for i in range(len(self.files) - 1, -1, -1):
            if predicate(self.files[i]):
                self.debug_print(" removing " + self.files[i])
                del self.files[i]
                found = True
        return found

    def include(self, pattern):
        """Include files that match 'pattern'."""
        found = [f for f in glob(pattern) if not os.path.isdir(f)]
        self.extend(found)
        return bool(found)

    def exclude(self, pattern):
        """Exclude files that match 'pattern'."""
        match = translate_pattern(pattern)
        return self._remove_files(match.match)

    def recursive_include(self, dir, pattern):
        """
        Include all files anywhere in 'dir/' that match the pattern.
        """
        full_pattern = os.path.join(dir, '**', pattern)
        found = [f for f in glob(full_pattern, recursive=True)
                 if not os.path.isdir(f)]
        self.extend(found)
        return bool(found)

    def recursive_exclude(self, dir, patterfrom __future__ import annotations

from cleo.helpers import argument

from poetry.console.commands.command import Command


class SourceShowCommand(Command):
    name = "source show"
    description = "Show information about sources configured for the project."

    arguments = [
        argument(
            "source",
            "Source(s) to show information for. Defaults to showing all sources.",
            optional=True,
            multiple=True,
        ),
    ]

    def handle(self) -> int:
        sources = self.poetry.get_sources()
        names = self.argument("source")

        if not sources:
            self.line("No sources configured for this project.")
            return 0

        if names and not any(s.name in names for s in sources):
            self.line_error(f"No source found with name(s): {', '.join(names)}")
            return 1

        bool_string = {
            True: "yes",
            False: "no",
        }

        for source in sources:
            if names and source.name not in names:
                continue

            table = self.table(style="compact")
            rows = [
                ["<info>name</>", f" : <c1>{source.name}</>"],
                ["<info>url</>", f" : {source.url}"],
                [
                    "<info>default</>",
                    f" : {bool_string.get(source.default, False)}",
                ],
                [
                    "<info>secondary</>",
                    f" : {bool_string.get(source.secondary, False)}",
                ],
            ]
            table.add_rows(rows)
            table.render()
            self.line("")

        return 0
