Skip to content

Commit b1a6c48

Browse files
Docs
1 parent 5706858 commit b1a6c48

File tree

5 files changed

+351
-26
lines changed

5 files changed

+351
-26
lines changed

CHANGELOG.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
---
9-
## [0.1.1] - 2025-10-17 - Native executable
9+
## [0.2.0] - 2025-11-12 - Native executable
10+
11+
> [!IMPORTANT]
12+
> Maven artifactId of Java lib changed from `jfiletreeprettyprinter` to `jfiletreeprettyprinter-core`
1013
1114
### Added
12-
- Run JFileTreePrettyPrinter using command line (options in external file)
13-
- Native executable attachment to the Github release
15+
- Run JFileTreePrettyPrinter in command line, using native executable on Windows, Linux, MacOS (see Github release attachments):
16+
`$ jfiletreeprettyprinter myFolder`
17+
- Scanning and rendering options in external file:
18+
`$ jfiletreeprettyprinter myFolder --options myOptions.json`
19+
20+
### Changed
21+
- Split code into 3 sub-modules: cli, core and examples
22+
23+
---
24+
## [0.1.1] - 2025-11-08 - Native executable (POC)
25+
26+
> [!CAUTION]
27+
> Do not use this version (was for proof of concept only).
1428
1529
---
1630
## [0.1.0] - 2025-10-13 - First beta release

README.md

Lines changed: 112 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ Supports various [options](#customization-options) to customize the directories
2727
<img src="assets/project-structure.png" alt="JFileTreePrettyPrint project structure, using JFileTreePrettyPrint"/>
2828
</p>
2929

30-
> [!IMPORTANT]
31-
> Complete documentation available in [wiki](https://github.com/ComputerDaddyGuy/JFileTreePrettyPrinter/wiki).
32-
3330
* [Why use JFileTreePrettyPrinter?](#why-use-jfiletreeprettyprinter)
34-
* [Requirements](#requirements)
35-
* [Import dependency](#import-dependency)
36-
* [Basic usage](#basic-usage)
37-
* [Customization options](#customization-options)
31+
* [Java lib](#java-lib)
32+
* [Requirements](#requirements)
33+
* [Import dependency](#import-dependency)
34+
* [Basic usage](#basic-usage)
35+
* [Customization options](#customization-options)
36+
* [Native CLI](#native-cli)
37+
* [Download and install](#download-and-install)
38+
* [Usage](#cli-usage)
39+
* [Options](#cli-options)
3840
* [Project Information](#project-information)
3941

4042
# Why use JFileTreePrettyPrinter?
@@ -44,11 +46,13 @@ Unlike a plain recursive `Files.walk()`, this library:
4446
- Supports **dynamic child limits** and **custom extensions** per line.
4547
- Is **dependency-free** (on runtime) and compatible with **Java 21+**.
4648

47-
# Requirements
49+
# Java lib
50+
51+
## Requirements
4852
- **Java 21 or later**
49-
- No runtime dependencies
53+
- No runtime dependencies!
5054

51-
# Import dependency
55+
## Import dependency
5256
For Maven, import this dependency to your `pom.xml`:
5357

5458
```xml
@@ -64,7 +68,7 @@ For Gradle:
6468
implementation "io.github.computerdaddyguy:jfiletreeprettyprinter-core:0.1.1"
6569
```
6670

67-
# Basic usage
71+
## Basic usage
6872
```java
6973
// Example: BasicUsage.java
7074
var printer = FileTreePrettyPrinter.createDefault(); // Create a printer with default options
@@ -94,7 +98,9 @@ base/
9498
> [!NOTE]
9599
> 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.
96100
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)
98104
99105
* [Filtering](#filtering)
100106
* [Sorting](#sorting)
@@ -105,7 +111,7 @@ base/
105111
* [Max depth](#max-depth)
106112
* [Tree format](#tree-format)
107113

108-
## Filtering
114+
### Filtering
109115
Files and directories can be selectively included or excluded using a custom `PathMatcher`.
110116

111117
Filtering applies independently to files and directories. Files are filtered only if their parent directory passes the directory filter.
@@ -139,7 +145,7 @@ filtering/
139145
└─ file_A.java
140146
```
141147

142-
## Sorting
148+
### Sorting
143149
Files and directories can be sorted using a custom comparator (default is alphabetical order).
144150
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.
145151

@@ -166,9 +172,10 @@ sorting/
166172
└─ y_file
167173
```
168174

169-
## Emojis ❤️
175+
### Emojis ❤️
170176
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!
172179

173180
```java
174181
// Example: Emojis.java
@@ -194,7 +201,7 @@ var prettyPrinter = FileTreePrettyPrinter.builder()
194201
└─ 🎬 file.avi
195202
```
196203

197-
## Child limit
204+
### Child limit
198205
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.
199206

200207
```java
@@ -250,7 +257,7 @@ child_limit_dynamic/
250257
└─ ...
251258
```
252259

253-
## Line extension
260+
### Line extension
254261
You can extend each displayed path with additional information by providing a custom `Function<Path, String>`.
255262
This is useful to annotate your tree with comments, display file sizes, or add domain-specific notes.
256263

@@ -290,7 +297,7 @@ line_extension/
290297
└─ application.properties // Config file
291298
```
292299

293-
## Compact directories
300+
### Compact directories
294301
Directory chains with a single child directory are fully expanded by default, but you can inline them into a single tree entry.
295302

296303
```java
@@ -310,7 +317,7 @@ single_directory_child/
310317
└─ file3
311318
```
312319

313-
## Max depth
320+
### Max depth
314321
You can customize the default max depth (default is 20).
315322

316323
```java
@@ -332,7 +339,7 @@ max_depth/
332339
└─ ... (max depth reached)
333340
```
334341

335-
## Tree format
342+
### Tree format
336343
Choose between different built-in tree formats, or create your own.
337344
The default is `UNICODE_BOX_DRAWING`, supported by all terminals, but you can also switch to use `CLASSIC_ASCII`.
338345

@@ -351,6 +358,90 @@ tree_format/
351358
|-- subFile_1
352359
`-- subFile_2
353360
```
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:
372+
```bash
373+
$ jfiletreeprettyprinter <folderName>
374+
```
375+
Example:
376+
```bash
377+
$ jfiletreeprettyprinter jfiletreeprettyprinter-examples/src/main/resources/base/
378+
base/
379+
├─ businessPlan.pdf
380+
├─ businessProject.pdf
381+
├─ cars/
382+
│ ├─ Ferrari.doc
383+
│ └─ Porsche.doc
384+
├─ diyIdeas.docx
385+
├─ giftIdeas.txt
386+
└─ images/
387+
├─ funnyCat.gif
388+
├─ holidays/
389+
│ ├─ meAtTheBeach.jpeg
390+
│ └─ meAtTheZoo.jpeg
391+
└─ landscape.jpeg
392+
```
393+
394+
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).
425+
```bash
426+
$ jfiletreeprettyprinter myFolder --options myOptions.json
427+
```
428+
429+
See an [example file](jfiletreeprettyprinter-examples/src/main/resources/cli/options/full-options.yaml).
430+
431+
### Options lookup order
432+
If no options file is explicitly provided as argument, the CLI automatically searches for one in the following order:
433+
1. **Inside the target path:**
434+
A `.prettyprint` file located within the directory being printed.
435+
1. **Beside the executable:**
436+
A `.prettyprint` file in the same folder as the native executable.
437+
1. **In the user’s home directory:**
438+
A `.prettyprint` file located in the user’s home folder.
439+
1. **Fallback:**
440+
If no configuration file is found, default options are used —
441+
equivalent to `PrettyPrintOptions.createDefault()`.
442+
443+
> [!TIP]
444+
> Using a `.prettyprint` file allows each project or directory to define its own display style — no need to pass extra parameters each time.
354445
355446
# Project Information
356447

ROADMAP.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030
- [x] Github actions
3131
- [x] Publish `0.0.x` **alpha** on Maven Central!
3232
- [x] Publish `0.x.0` **beta** on Maven Central!
33+
- [x] **Native CLI**
34+
- [x] Options in external file
35+
- [x] Distribute executable file with release in Github
3336

3437
## To do
3538
- [ ] Gather feedback
36-
- [x] Use as command line (options as arguments of provided in external file)
37-
- [x] Executable file distributed with release files in Github
3839

3940
## Backlog / To analyze / To implement if requested
4041
- [ ] Rework/fix Github wiki to be up to date

0 commit comments

Comments
 (0)