dirlens 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/dirlens.py +17 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -127,6 +127,7 @@ Desktop/ (2 dirs, 2 files, 3.74 MB)
|
|
|
127
127
|
- **JSON出力** — `--json` で機械可読な構造データを出力、スクリプト連携に
|
|
128
128
|
- **HTMLレポート** — `--html` でブラウザで閲覧できる折りたたみツリーを生成
|
|
129
129
|
- **クリップボードコピー** — `-c` で出力を自動コピー、AIチャットへの貼り付けが一発
|
|
130
|
+
- **AIモード** — `--ai` 一発で gitignore除外・日時・Markdown・クリップボードコピーを全適用
|
|
130
131
|
- **隠しファイル対応** — `-a` で表示切り替え(アイテム数・統計にも反映)
|
|
131
132
|
- **サイズ順ソート** — `-s` で大きいものから表示
|
|
132
133
|
|
|
@@ -135,6 +136,13 @@ Desktop/ (2 dirs, 2 files, 3.74 MB)
|
|
|
135
136
|
## 使い方
|
|
136
137
|
|
|
137
138
|
```bash
|
|
139
|
+
# ── AI チャットへの貼り付け(最もよく使うコマンド)─────────────
|
|
140
|
+
# gitignore除外 + 日時 + Markdown + クリップボードコピーを一発で実行
|
|
141
|
+
dirlens --ai
|
|
142
|
+
|
|
143
|
+
# 深さを指定したい場合は組み合わせ可能
|
|
144
|
+
dirlens --ai -d 3
|
|
145
|
+
|
|
138
146
|
# カレントディレクトリを表示
|
|
139
147
|
dirlens
|
|
140
148
|
|
|
@@ -191,10 +199,6 @@ dirlens -c
|
|
|
191
199
|
# カラーなし(パイプ・ファイル書き出し向け)
|
|
192
200
|
dirlens --no-color
|
|
193
201
|
|
|
194
|
-
# ── AI チャットへの貼り付け(推奨の組み合わせ)────────────────
|
|
195
|
-
# gitignore 除外 → Markdown → クリップボードコピー(そのまま貼れる)
|
|
196
|
-
dirlens -g -m -c
|
|
197
|
-
|
|
198
202
|
# テキストファイルに書き出す
|
|
199
203
|
dirlens --no-color > dirlens.txt
|
|
200
204
|
```
|
|
@@ -206,6 +210,7 @@ dirlens --no-color > dirlens.txt
|
|
|
206
210
|
| オプション | 省略形 | 説明 |
|
|
207
211
|
|---------------------|----------|------------------------------------------------------------|
|
|
208
212
|
| `path` | — | 対象ディレクトリ(省略時はカレント) |
|
|
213
|
+
| **`--ai`** | — | **`-g --date -m -c` のショートカット。AIチャット貼り付け専用** |
|
|
209
214
|
| `--depth N` | `-d N` | 表示する最大の深さ |
|
|
210
215
|
| `--all` | `-a` | 隠しファイル・ディレクトリも表示 |
|
|
211
216
|
| `--sort-size` | `-s` | サイズが大きい順に並べる |
|
package/dirlens.py
CHANGED
|
@@ -94,6 +94,11 @@ def copy_to_clipboard(text):
|
|
|
94
94
|
except Exception:
|
|
95
95
|
return False
|
|
96
96
|
|
|
97
|
+
import re as _re
|
|
98
|
+
def strip_ansi(text):
|
|
99
|
+
"""ANSIエスケープシーケンスを除去する。"""
|
|
100
|
+
return _re.sub(r'\033\[[0-9;]*[mK]', '', text)
|
|
101
|
+
|
|
97
102
|
|
|
98
103
|
# ─── 絵文字 ───────────────────────────────────────────────────
|
|
99
104
|
_EMOJI_EXT = {
|
|
@@ -460,6 +465,7 @@ def main():
|
|
|
460
465
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
461
466
|
epilog=(
|
|
462
467
|
"使用例:\n"
|
|
468
|
+
" dirlens --ai AIチャット貼り付け用形式で出力(推奨)\n"
|
|
463
469
|
" dirlens -g -m -c gitignore除外→Markdown→クリップボードコピー\n"
|
|
464
470
|
" dirlens --bar ディスク占有率バーを表示\n"
|
|
465
471
|
" dirlens --min-size 1M 1MB以上のファイルのみ\n"
|
|
@@ -501,8 +507,17 @@ def main():
|
|
|
501
507
|
help="HTMLレポートを生成 (デフォルト: dirlens.html)")
|
|
502
508
|
ap.add_argument("-c", "--copy", action="store_true",
|
|
503
509
|
help="出力をクリップボードにコピー")
|
|
510
|
+
ap.add_argument("--ai", action="store_true",
|
|
511
|
+
help="-g --date -m -c のショートカット。AIチャットへの貼り付けに最適化")
|
|
504
512
|
args = ap.parse_args()
|
|
505
513
|
|
|
514
|
+
# --ai は -g --date -m -c のショートカット
|
|
515
|
+
if args.ai:
|
|
516
|
+
args.gitignore = True
|
|
517
|
+
args.date = True
|
|
518
|
+
args.markdown = True
|
|
519
|
+
args.copy = True
|
|
520
|
+
|
|
506
521
|
if args.no_color or args.markdown or args.json:
|
|
507
522
|
USE_COLOR = False
|
|
508
523
|
|
|
@@ -573,8 +588,8 @@ def main():
|
|
|
573
588
|
if args.copy:
|
|
574
589
|
sys.stdout = _old
|
|
575
590
|
text = _buf.getvalue()
|
|
576
|
-
print(text, end="")
|
|
577
|
-
ok = copy_to_clipboard(text)
|
|
591
|
+
print(text, end="") # ターミナルにはカラーつきで表示
|
|
592
|
+
ok = copy_to_clipboard(strip_ansi(text)) # クリップボードにはANSIコードなし
|
|
578
593
|
msg = "✓ クリップボードにコピーしました" if ok \
|
|
579
594
|
else "✗ コピー失敗 (pbcopy / xclip / wl-copy が必要)"
|
|
580
595
|
print(c(msg, BOLD, GREEN if ok else DIM), file=sys.stderr)
|