treex-cli 0.1.4__tar.gz → 0.1.6__tar.gz
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.
- {treex_cli-0.1.4/treex_cli.egg-info → treex_cli-0.1.6}/PKG-INFO +10 -8
- {treex_cli-0.1.4 → treex_cli-0.1.6}/README.md +8 -6
- {treex_cli-0.1.4 → treex_cli-0.1.6}/pyproject.toml +2 -2
- {treex_cli-0.1.4 → treex_cli-0.1.6}/treex.py +56 -18
- {treex_cli-0.1.4 → treex_cli-0.1.6/treex_cli.egg-info}/PKG-INFO +10 -8
- {treex_cli-0.1.4 → treex_cli-0.1.6}/LICENSE +0 -0
- {treex_cli-0.1.4 → treex_cli-0.1.6}/setup.cfg +0 -0
- {treex_cli-0.1.4 → treex_cli-0.1.6}/treex_cli.egg-info/SOURCES.txt +0 -0
- {treex_cli-0.1.4 → treex_cli-0.1.6}/treex_cli.egg-info/dependency_links.txt +0 -0
- {treex_cli-0.1.4 → treex_cli-0.1.6}/treex_cli.egg-info/entry_points.txt +0 -0
- {treex_cli-0.1.4 → treex_cli-0.1.6}/treex_cli.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: treex-cli
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: List directory contents as a tree with file metadata
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: List directory contents as a tree with file and directory metadata
|
|
5
5
|
Author: Corey Goldberg
|
|
6
6
|
Maintainer: Corey Goldberg
|
|
7
7
|
License-Expression: MIT
|
|
@@ -25,7 +25,7 @@ Dynamic: license-file
|
|
|
25
25
|
|
|
26
26
|
# treex
|
|
27
27
|
|
|
28
|
-
## List directory contents as a tree with file metadata
|
|
28
|
+
## List directory contents as a tree with file and directory metadata
|
|
29
29
|
|
|
30
30
|
- Copyright (c) 2026 [Corey Goldberg][github-profile]
|
|
31
31
|
- Development: [GitHub][github-repo]
|
|
@@ -37,12 +37,13 @@ Dynamic: license-file
|
|
|
37
37
|
## About
|
|
38
38
|
|
|
39
39
|
`treex` is a command-line utility that recursively scans a directory and
|
|
40
|
-
|
|
40
|
+
lists its contents as a tree along with file and directory metadata.
|
|
41
41
|
|
|
42
|
-
-
|
|
42
|
+
- Shows human-readable file sizes
|
|
43
|
+
- Shows recursive directory sizes
|
|
43
44
|
- Shows line counts for text files
|
|
44
45
|
- Identifies binary and unreadable files by type
|
|
45
|
-
- Optionally
|
|
46
|
+
- Optionally shows modification timestamps
|
|
46
47
|
- Respects `.gitignore` rules when Git is installed
|
|
47
48
|
|
|
48
49
|
----
|
|
@@ -99,9 +100,9 @@ Install `treex` from [PyPI][pypi-home] using either `pip` or `pipx`:
|
|
|
99
100
|
|
|
100
101
|
```
|
|
101
102
|
$ treex --help
|
|
102
|
-
usage: treex [-h] [-a] [-m] [-s] [directory]
|
|
103
|
+
usage: treex [-h] [-a] [-m] [-q] [-s] [directory]
|
|
103
104
|
|
|
104
|
-
List directory contents as a tree with file metadata.
|
|
105
|
+
List directory contents as a tree with file and directory metadata.
|
|
105
106
|
|
|
106
107
|
positional arguments:
|
|
107
108
|
directory directory to scan (default: current directory)
|
|
@@ -110,6 +111,7 @@ options:
|
|
|
110
111
|
-h, --help show this help message and exit
|
|
111
112
|
-a, --all show all files (including those ignored by Git)
|
|
112
113
|
-m, --modified show file modification times
|
|
114
|
+
-q, --quiet don't show file metadata
|
|
113
115
|
-s, --summary show summary only
|
|
114
116
|
```
|
|
115
117
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# treex
|
|
2
2
|
|
|
3
|
-
## List directory contents as a tree with file metadata
|
|
3
|
+
## List directory contents as a tree with file and directory metadata
|
|
4
4
|
|
|
5
5
|
- Copyright (c) 2026 [Corey Goldberg][github-profile]
|
|
6
6
|
- Development: [GitHub][github-repo]
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
## About
|
|
13
13
|
|
|
14
14
|
`treex` is a command-line utility that recursively scans a directory and
|
|
15
|
-
|
|
15
|
+
lists its contents as a tree along with file and directory metadata.
|
|
16
16
|
|
|
17
|
-
-
|
|
17
|
+
- Shows human-readable file sizes
|
|
18
|
+
- Shows recursive directory sizes
|
|
18
19
|
- Shows line counts for text files
|
|
19
20
|
- Identifies binary and unreadable files by type
|
|
20
|
-
- Optionally
|
|
21
|
+
- Optionally shows modification timestamps
|
|
21
22
|
- Respects `.gitignore` rules when Git is installed
|
|
22
23
|
|
|
23
24
|
----
|
|
@@ -74,9 +75,9 @@ Install `treex` from [PyPI][pypi-home] using either `pip` or `pipx`:
|
|
|
74
75
|
|
|
75
76
|
```
|
|
76
77
|
$ treex --help
|
|
77
|
-
usage: treex [-h] [-a] [-m] [-s] [directory]
|
|
78
|
+
usage: treex [-h] [-a] [-m] [-q] [-s] [directory]
|
|
78
79
|
|
|
79
|
-
List directory contents as a tree with file metadata.
|
|
80
|
+
List directory contents as a tree with file and directory metadata.
|
|
80
81
|
|
|
81
82
|
positional arguments:
|
|
82
83
|
directory directory to scan (default: current directory)
|
|
@@ -85,6 +86,7 @@ options:
|
|
|
85
86
|
-h, --help show this help message and exit
|
|
86
87
|
-a, --all show all files (including those ignored by Git)
|
|
87
88
|
-m, --modified show file modification times
|
|
89
|
+
-q, --quiet don't show file metadata
|
|
88
90
|
-s, --summary show summary only
|
|
89
91
|
```
|
|
90
92
|
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "treex-cli"
|
|
7
|
-
version = "0.1.
|
|
8
|
-
description="List directory contents as a tree with file metadata"
|
|
7
|
+
version = "0.1.6"
|
|
8
|
+
description="List directory contents as a tree with file and directory metadata"
|
|
9
9
|
license = "MIT"
|
|
10
10
|
license-files = ["LICENSE"]
|
|
11
11
|
authors = [{name = "Corey Goldberg"}]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
"""List directory contents as a tree with file metadata.
|
|
5
|
+
"""List directory contents as a tree with file and directory metadata.
|
|
6
6
|
|
|
7
7
|
The directory tree is rendered using Unicode box-drawing characters.
|
|
8
8
|
|
|
@@ -60,15 +60,17 @@ class GitIgnore:
|
|
|
60
60
|
return result.returncode == 0
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
def _format_size(size):
|
|
63
|
+
def _format_size(size):
|
|
64
64
|
"""Format bytes as a human-readable size."""
|
|
65
65
|
units = ["B", "KB", "MB", "GB", "TB"]
|
|
66
66
|
for unit in units:
|
|
67
|
-
if size < 1024
|
|
67
|
+
if size < 1024:
|
|
68
68
|
if unit == "B":
|
|
69
69
|
return f"{size} B"
|
|
70
70
|
return f"{size:.1f} {unit}"
|
|
71
71
|
size /= 1024
|
|
72
|
+
# Anything above 1 TB is shown in TB
|
|
73
|
+
return f"{size:.1f} TB"
|
|
72
74
|
|
|
73
75
|
|
|
74
76
|
def _format_modified(timestamp):
|
|
@@ -147,44 +149,60 @@ def _collect_tree(
|
|
|
147
149
|
stats,
|
|
148
150
|
gitignore,
|
|
149
151
|
rows,
|
|
152
|
+
show_metadata,
|
|
150
153
|
show_modified,
|
|
151
154
|
):
|
|
152
155
|
"""Walk the tree once and collect the output rows."""
|
|
153
156
|
entries = _get_tree_entries(path, gitignore)
|
|
154
157
|
if entries is None:
|
|
155
158
|
rows.append((prefix + "└── [permission denied]", None))
|
|
156
|
-
return
|
|
159
|
+
return 0
|
|
160
|
+
total_size = 0
|
|
157
161
|
for index, entry in enumerate(entries):
|
|
158
162
|
is_last = index == len(entries) - 1
|
|
159
163
|
connector = "└── " if is_last else "├── "
|
|
160
164
|
tree_name = prefix + connector + entry.name
|
|
161
165
|
if entry.is_dir():
|
|
162
166
|
stats["directories"] += 1
|
|
167
|
+
row_index = len(rows)
|
|
163
168
|
rows.append((tree_name, None))
|
|
164
169
|
# Indent nested entries, preserving the tree's vertical branch
|
|
165
170
|
extension = " " if is_last else "│ "
|
|
166
|
-
_collect_tree(
|
|
171
|
+
dir_size = _collect_tree(
|
|
167
172
|
entry,
|
|
168
173
|
prefix + extension,
|
|
169
174
|
stats,
|
|
170
175
|
gitignore,
|
|
171
176
|
rows,
|
|
177
|
+
show_metadata,
|
|
172
178
|
show_modified,
|
|
173
179
|
)
|
|
180
|
+
total_size += dir_size
|
|
181
|
+
if show_metadata:
|
|
182
|
+
rows[row_index] = (tree_name, (_format_size(dir_size), None, None))
|
|
174
183
|
elif entry.is_file():
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
if show_metadata:
|
|
185
|
+
size_text, info, size, modified = _file_metadata(entry)
|
|
186
|
+
stats["files"] += 1
|
|
187
|
+
stats["total_size"] += size
|
|
188
|
+
total_size += size
|
|
189
|
+
timestamp = modified if show_modified else None
|
|
190
|
+
rows.append((tree_name, (size_text, info, timestamp)))
|
|
191
|
+
else:
|
|
192
|
+
stats["files"] += 1
|
|
193
|
+
stats["total_size"] = None
|
|
194
|
+
rows.append((tree_name, None))
|
|
195
|
+
return total_size
|
|
180
196
|
|
|
181
197
|
|
|
182
198
|
def print_summary(stats):
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
199
|
+
directories = stats["directories"]
|
|
200
|
+
files = stats["files"]
|
|
201
|
+
total_size = stats["total_size"]
|
|
202
|
+
summary = f"{directories:,} directories • {files:,} files"
|
|
203
|
+
if total_size:
|
|
204
|
+
summary += f" • {_format_size(total_size)}"
|
|
205
|
+
print(summary)
|
|
188
206
|
|
|
189
207
|
|
|
190
208
|
def print_tree(
|
|
@@ -192,6 +210,7 @@ def print_tree(
|
|
|
192
210
|
prefix="",
|
|
193
211
|
stats=None,
|
|
194
212
|
gitignore=None,
|
|
213
|
+
show_metadata=True,
|
|
195
214
|
show_modified=False,
|
|
196
215
|
show_tree=True,
|
|
197
216
|
):
|
|
@@ -200,7 +219,15 @@ def print_tree(
|
|
|
200
219
|
stats = {"directories": 0, "files": 0, "total_size": 0}
|
|
201
220
|
rows = []
|
|
202
221
|
# Walk the filesystem once and collect the output
|
|
203
|
-
_collect_tree(
|
|
222
|
+
_collect_tree(
|
|
223
|
+
Path(directory),
|
|
224
|
+
prefix,
|
|
225
|
+
stats,
|
|
226
|
+
gitignore,
|
|
227
|
+
rows,
|
|
228
|
+
show_metadata,
|
|
229
|
+
show_modified,
|
|
230
|
+
)
|
|
204
231
|
if show_tree:
|
|
205
232
|
# Align file metadata with the longest tree/name
|
|
206
233
|
max_tree_name_width = max(
|
|
@@ -212,7 +239,9 @@ def print_tree(
|
|
|
212
239
|
print(tree_name)
|
|
213
240
|
continue
|
|
214
241
|
size_text, info, modified = file_info_data
|
|
215
|
-
output = f"{tree_name:<{max_tree_name_width}}{size_text:>10}
|
|
242
|
+
output = f"{tree_name:<{max_tree_name_width}}{size_text:>10}"
|
|
243
|
+
if info is not None:
|
|
244
|
+
output += f" {info:<10}"
|
|
216
245
|
if modified is not None:
|
|
217
246
|
output += f" {modified}"
|
|
218
247
|
print(output)
|
|
@@ -222,7 +251,8 @@ def print_tree(
|
|
|
222
251
|
def parse_args(argv=None):
|
|
223
252
|
"""Parse command-line arguments."""
|
|
224
253
|
parser = argparse.ArgumentParser(
|
|
225
|
-
description="List directory contents as a tree with
|
|
254
|
+
description="List directory contents as a tree with "
|
|
255
|
+
"file and directory metadata.",
|
|
226
256
|
)
|
|
227
257
|
parser.add_argument(
|
|
228
258
|
"directory",
|
|
@@ -243,6 +273,12 @@ def parse_args(argv=None):
|
|
|
243
273
|
action="store_true",
|
|
244
274
|
help="show file modification times",
|
|
245
275
|
)
|
|
276
|
+
parser.add_argument(
|
|
277
|
+
"-q",
|
|
278
|
+
"--quiet",
|
|
279
|
+
action="store_true",
|
|
280
|
+
help="don't show file metadata",
|
|
281
|
+
)
|
|
246
282
|
parser.add_argument(
|
|
247
283
|
"-s",
|
|
248
284
|
"--summary",
|
|
@@ -261,11 +297,13 @@ def main():
|
|
|
261
297
|
# Only initialize Git support if it will be used
|
|
262
298
|
gitignore = None if args.all else GitIgnore(path)
|
|
263
299
|
show_tree = not args.summary
|
|
300
|
+
show_metadata = not args.quiet
|
|
264
301
|
if show_tree:
|
|
265
302
|
print(path)
|
|
266
303
|
stats = print_tree(
|
|
267
304
|
path,
|
|
268
305
|
gitignore=gitignore,
|
|
306
|
+
show_metadata=show_metadata,
|
|
269
307
|
show_modified=args.modified,
|
|
270
308
|
show_tree=show_tree,
|
|
271
309
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: treex-cli
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: List directory contents as a tree with file metadata
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: List directory contents as a tree with file and directory metadata
|
|
5
5
|
Author: Corey Goldberg
|
|
6
6
|
Maintainer: Corey Goldberg
|
|
7
7
|
License-Expression: MIT
|
|
@@ -25,7 +25,7 @@ Dynamic: license-file
|
|
|
25
25
|
|
|
26
26
|
# treex
|
|
27
27
|
|
|
28
|
-
## List directory contents as a tree with file metadata
|
|
28
|
+
## List directory contents as a tree with file and directory metadata
|
|
29
29
|
|
|
30
30
|
- Copyright (c) 2026 [Corey Goldberg][github-profile]
|
|
31
31
|
- Development: [GitHub][github-repo]
|
|
@@ -37,12 +37,13 @@ Dynamic: license-file
|
|
|
37
37
|
## About
|
|
38
38
|
|
|
39
39
|
`treex` is a command-line utility that recursively scans a directory and
|
|
40
|
-
|
|
40
|
+
lists its contents as a tree along with file and directory metadata.
|
|
41
41
|
|
|
42
|
-
-
|
|
42
|
+
- Shows human-readable file sizes
|
|
43
|
+
- Shows recursive directory sizes
|
|
43
44
|
- Shows line counts for text files
|
|
44
45
|
- Identifies binary and unreadable files by type
|
|
45
|
-
- Optionally
|
|
46
|
+
- Optionally shows modification timestamps
|
|
46
47
|
- Respects `.gitignore` rules when Git is installed
|
|
47
48
|
|
|
48
49
|
----
|
|
@@ -99,9 +100,9 @@ Install `treex` from [PyPI][pypi-home] using either `pip` or `pipx`:
|
|
|
99
100
|
|
|
100
101
|
```
|
|
101
102
|
$ treex --help
|
|
102
|
-
usage: treex [-h] [-a] [-m] [-s] [directory]
|
|
103
|
+
usage: treex [-h] [-a] [-m] [-q] [-s] [directory]
|
|
103
104
|
|
|
104
|
-
List directory contents as a tree with file metadata.
|
|
105
|
+
List directory contents as a tree with file and directory metadata.
|
|
105
106
|
|
|
106
107
|
positional arguments:
|
|
107
108
|
directory directory to scan (default: current directory)
|
|
@@ -110,6 +111,7 @@ options:
|
|
|
110
111
|
-h, --help show this help message and exit
|
|
111
112
|
-a, --all show all files (including those ignored by Git)
|
|
112
113
|
-m, --modified show file modification times
|
|
114
|
+
-q, --quiet don't show file metadata
|
|
113
115
|
-s, --summary show summary only
|
|
114
116
|
```
|
|
115
117
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|