a8m / a8m/tree

Allow directories to be ignored with -I/IPattern

オープン
#11 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。