You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var printer =FileTreePrettyPrinter.createDefault(); // Create a printer with default options
@@ -94,7 +98,9 @@ base/
94
98
> [!NOTE]
95
99
> In case of error while reading directories or files, an [UncheckedIOException](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/UncheckedIOException.html) is thrown.
96
100
97
-
# Customization options
101
+
## Customization options
102
+
> [!NOTE]
103
+
> All code below is availabe in [jfiletreeprettyprinter-examples] submodule.(jfiletreeprettyprinter-examples\src\main\java\io\github\computerdaddyguy\jfiletreeprettyprinter\example)
98
104
99
105
*[Filtering](#filtering)
100
106
*[Sorting](#sorting)
@@ -105,7 +111,7 @@ base/
105
111
*[Max depth](#max-depth)
106
112
*[Tree format](#tree-format)
107
113
108
-
## Filtering
114
+
###Filtering
109
115
Files and directories can be selectively included or excluded using a custom `PathMatcher`.
110
116
111
117
Filtering applies independently to files and directories. Files are filtered only if their parent directory passes the directory filter.
@@ -139,7 +145,7 @@ filtering/
139
145
└─ file_A.java
140
146
```
141
147
142
-
## Sorting
148
+
###Sorting
143
149
Files and directories can be sorted using a custom comparator (default is alphabetical order).
144
150
If the provided comparator considers two paths equal (i.e., returns `0`), an alphabetical comparator is applied as a tie-breaker to ensure consistent results across all systems.
145
151
@@ -166,9 +172,10 @@ sorting/
166
172
└─ y_file
167
173
```
168
174
169
-
## Emojis ❤️
175
+
###Emojis ❤️
170
176
You can choose to use default built-in emojis, or define your own emoji mapping.
171
-
Folders use the 📂 emoji, and files will have an emoji depending on their extension (when applicable).
177
+
Folders use the 📂 emoji, and files will have an emoji depending on their name or extension (when applicable).
178
+
Define your own emoji mappings with the `EmojiMapping` class!
172
179
173
180
```java
174
181
// Example: Emojis.java
@@ -194,7 +201,7 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
194
201
└─ 🎬 file.avi
195
202
```
196
203
197
-
## Child limit
204
+
###Child limit
198
205
You can set a fixed limit to the number of children displayed for each directory. Each directory and file that pass the filter (if set) counts for one.
199
206
200
207
```java
@@ -250,7 +257,7 @@ child_limit_dynamic/
250
257
└─ ...
251
258
```
252
259
253
-
## Line extension
260
+
###Line extension
254
261
You can extend each displayed path with additional information by providing a custom `Function<Path, String>`.
255
262
This is useful to annotate your tree with comments, display file sizes, or add domain-specific notes.
256
263
@@ -290,7 +297,7 @@ line_extension/
290
297
└─ application.properties // Config file
291
298
```
292
299
293
-
## Compact directories
300
+
###Compact directories
294
301
Directory chains with a single child directory are fully expanded by default, but you can inline them into a single tree entry.
295
302
296
303
```java
@@ -310,7 +317,7 @@ single_directory_child/
310
317
└─ file3
311
318
```
312
319
313
-
## Max depth
320
+
###Max depth
314
321
You can customize the default max depth (default is 20).
315
322
316
323
```java
@@ -332,7 +339,7 @@ max_depth/
332
339
└─ ... (max depth reached)
333
340
```
334
341
335
-
## Tree format
342
+
###Tree format
336
343
Choose between different built-in tree formats, or create your own.
337
344
The default is `UNICODE_BOX_DRAWING`, supported by all terminals, but you can also switch to use `CLASSIC_ASCII`.
338
345
@@ -351,6 +358,90 @@ tree_format/
351
358
|-- subFile_1
352
359
`-- subFile_2
353
360
```
361
+
# Native CLI
362
+
363
+
## Download and install
364
+
You can download the latest CLI release directly from https://github.com/ComputerDaddyGuy/JFileTreePrettyPrinter/releases/latest.
365
+
Choose the archive for your platform (Windows, Linux, or macOS), download it, and unzip it anywhere on your system.
366
+
367
+
> [!NOTE]
368
+
> If desired, add the executable’s folder to your system’s `PATH` variable to run it from any directory.
369
+
370
+
## CLI usage
371
+
To pretty-print a folder and its contents, simply run:
To get an overview of the CLI’s capabilities and available options:
395
+
```bash
396
+
$ jfiletreeprettyprinter --help
397
+
Usage: prettyprint [-dhV] [-o] [<target>]
398
+
Pretty-prints directory structure
399
+
[<target>] The path to pretty print
400
+
-d, --debug debug mode
401
+
-h, --help Show this help message and exit.
402
+
-o, --options the options file
403
+
-V, --version Print version information and exit.
404
+
```
405
+
406
+
### UTF-8 console
407
+
If the tree symbols appear as garbled characters (e.g., Ôöé instead of ├─), your console is likely not using UTF-8 encoding.
408
+
409
+
**Set UTF-8 Encoding**
410
+
```
411
+
# Windows
412
+
> chcp 65001
413
+
414
+
# Linux (bash, zsh)
415
+
$ export LANG=en_US.UTF-8
416
+
417
+
# macOS (bash, zsh)
418
+
$ export LC_CTYPE=UTF-8
419
+
```
420
+
421
+
## CLI options
422
+
The native CLI supports (almost all) pretty print options through an external JSON or YAML configuration file provided as an argument.
423
+
424
+
This configuration file must comply with the [CLI options file schema](jfiletreeprettyprinter-cli/src/main/resources/schemas/jfiletreeprettyprinter-options.schema.json).
0 commit comments