Allow directories to be ignored with -I/IPattern
- 主要语言
- Go
- 星标
- 105
- 派生
- 17
- PR 合并指标
- 30 天内没有已合并 PR
描述
Currently, the `-I` flag and `IPattern` option only ignore _files_ with the given pattern. Directories matching the pattern remain in the tree.
Would it be possible to also ignore directories? I know this would break the existing API, so I'm not sure if there should be a new option for this, rather than change the existing behaviour.
The `tree` command installed with Homebrew from http://mama.indstate.edu/users/ice/tree/ does ignore directories in addition to files, as shown below:
``` bash session
$ mkdir -p rootdir/building/flowers rootdir/{road,ocean}
$ touch rootdir/building/b.txt rootdir/building/flowers/f.txt rootdir/road/r.txt rootdir/ocean/o.txt
$ tree rootdir/
rootdir/
├── building
│ ├── b.txt
│ └── flowers
│ └── f.txt
├── ocean
│ └── o.txt
└── road
└── r.txt
4 directories, 4 files
$ $GOPATH/src/github.com/a8m/tree/tree rootdir/
rootdir/
├── building
│ ├── b.txt
│ └── flowers
│ └── f.txt
├── ocean
│ └── o.txt
└── road
└── r.txt
4 directories, 4 files
$ tree -I building rootdir/
rootdir/
├── ocean
│ └── o.txt
└── road
└── r.txt
2 directories, 2 files
$ $GOPATH/src/github.com/a8m/tree/tree -I building rootdir/
rootdir/
├── building
│ ├── b.txt
│ └── flowers
│ └── f.txt
├── ocean
│ └── o.txt
└── road
└── r.txt
4 directories, 4 files
```
I'd be happy to work on this, but I'm not sure if it's something you want to add to the project. If so, I'd appreciate some guidance about how to handle backward compatibility.
Thanks!
贡献指南
这个仓库没有索引到贡献指南
调研方向
Look at the code handling the -I flag and IPattern option, likely in the main package or a walker. Understand how file patterns are matched and filtered. The change is to also skip directories matching the pattern, which may affect tree traversal logic. Check for existing tests related to -I to update and ensure backward compatibility considerations are addressed.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go
- 领域
- cli
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 65/100