Skip to content

Args --children is not recursive and --recursive does not apply to --children #1512

@lhaagsma

Description

@lhaagsma

The function open_all as part of target.py does not support passing --recursive or recursive=True to open_children and this is likely desired when calling target-query with -~~children perhaps optionally with ~~ ~~recursive or should ~~-children always be recursive?.

    def open_all(
        cls, paths: str | Path | list[str \| Path], include_children: bool = False, \*, apply: bool = True
    ) -> Iterator[Self]:
        """Yield all targets from one or more paths or directories.

        If the path is a directory, iterate files one directory deep.

        Args:
            paths: A list of paths to load ``Targets`` from.
                   If the path is a ``os.PathLike`` object, it will be used as-is.
                   If the path is a string and looks like a URI, it will be parsed as such.
                   If the path is a string and does not look like a URI, it will be treated as a local path.
            include_children: Whether to recursively open child targets.

        Raises:
            TargetError: Raised when not a single ``Target`` can be loaded.
        """


        def _open_all(spec: str | Path, include_children: bool = False, \*, apply: bool = True) -> Iterator[Target]:

source: https://github.com/fox-it/dissect.target/blob/a7cc81c09a84fd06ee75b8eed661eed1446ca28d/dissect/target/target.py#L323C2-L341C115

Will create a PR that causes the following behavior:
--list-children and --children go one (1) layer deep
--list-children and -~~children with ~~-recursive will go as deep as digitally possible.
I will modify argeparse to reflect this as good as possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions