Support operation on a sub-tree of stages
kevin-hanselman opened this issue · 0 comments
Currently, the primary commands of Dud follow the convention that no inputs (e.g., dud commit
alone) means operate on all stages. This feature would add support for operating on all stages within and below the current working directory. For example:
project-root/ $ dud status
# shows status for all stages
project-root/ $ cd subdir
project-root/subdir $ dud status
# shows status for all stages starting with subdir/
project-root/subdir $ dud status --all
# shows status for all stages (the current default behavior)
project-root/subdir $ dud status ../other-subdir/foo.yaml
# shows status for other-subdir/foo.yaml
# i.e., no change in current behavior when stages are explicitly specified
This would make working on projects with many distinct groupings of stages a bit easier. Organizing stages using the filesystem (rather than a monolithic file) is an intentional design choice in Dud, and this would be a sensible quality-of-life improvement for said design.
Alternatively, we could make a --tree
option or similar that enables this behavior explicitly. I generally lean towards explicit over implicit, so this may be a better approach. Making this option explicit would also match Git, which has no such scope-limiting option that I'm aware of (unless you count submodules), thus reducing surprising behavior.
To accomplish this sub-tree behavior today, you'd have to manually pass each stage in a sub-tree to Dud. None of them are particularly clear, nor simple (these are pseudocode):
# depends on your shell's globbing behavior
# will break if there's other YAML files in the tree
project-root/subdir $ dud status **.yaml
# this grep command won't quite work; you need to strip the absolute paths
project-root/subdir $ grep -F "$(pwd)" ../../.dud/index | xargs dud status