Skip to content

Commit c90de79

Browse files
Custom tree format option (#12)
1 parent 8392ef2 commit c90de79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+397
-231
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,13 @@ max_depth/
333333
```
334334

335335
## Tree format
336-
Choose between different tree formats.
336+
Choose between different built-in tree formats, or create your own.
337337
The default is `UNICODE_BOX_DRAWING`, supported by all terminals, but you can also switch to use `CLASSIC_ASCII`.
338338

339339
```java
340340
// Example: FileTreeFormat.java
341341
var prettyPrinter = FileTreePrettyPrinter.builder()
342-
.customizeOptions(options -> options.withTreeFormat(TreeFormat.CLASSIC_ASCII))
342+
.customizeOptions(options -> options.withTreeFormat(TreeFormats.CLASSIC_ASCII))
343343
.build();
344344
```
345345

@@ -352,9 +352,6 @@ tree_format/
352352
`-- subFile_2
353353
```
354354

355-
> [!TIP]
356-
> *Idea for a future version: option to allow usage of custom format*
357-
358355
# Project Information
359356

360357
* See [🆕CHANGELOG.md](CHANGELOG.md) for a list of released versions and detailed changes.

ROADMAP.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
- [x] **Features**
55
- [x] Option: filtering
66
- [x] Option: ordering
7-
- [x] Option: emojis
8-
- [x] Option: custom emojis mapping
7+
- [x] Option: emojis (+ custom mapping)
98
- [x] Option: compact directories display
109
- [x] Option: line extension (=additional text after the file name)
1110
- [x] Option: children limit (static & dynamic)
12-
- [x] Option: tree format Unicode box drawing / classic ASCII
11+
- [x] Option: tree format (+ custom mapping)
1312
- [x] Option: max directory depth
1413
- [x] **Helpers**
1514
- [x] Path matchers
@@ -29,10 +28,11 @@
2928
- [x] SonarCloud integration
3029
- [x] **Workflows**
3130
- [x] Github actions
32-
- [x] Publish on Maven Central!
31+
- [x] Publish `0.0.x` alpha on Maven Central!
3332

3433
## To do
35-
- [ ] Option: custom tree format
34+
- [ ] Gather feedback
35+
- [ ] Publish `0.x.0` beta on Maven Central!
3636

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

assets/project-structure.png

21 KB
Loading

src/example/java/io/github/computerdaddyguy/jfiletreeprettyprinter/example/ChildLimitDynamic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.github.computerdaddyguy.jfiletreeprettyprinter.example;
22

3-
import io.github.computerdaddyguy.jfiletreeprettyprinter.ChildLimits;
43
import io.github.computerdaddyguy.jfiletreeprettyprinter.FileTreePrettyPrinter;
5-
import io.github.computerdaddyguy.jfiletreeprettyprinter.PathMatchers;
4+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.ChildLimits;
5+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.PathMatchers;
66

77
public class ChildLimitDynamic {
88

src/example/java/io/github/computerdaddyguy/jfiletreeprettyprinter/example/FileTreeFormat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package io.github.computerdaddyguy.jfiletreeprettyprinter.example;
22

33
import io.github.computerdaddyguy.jfiletreeprettyprinter.FileTreePrettyPrinter;
4-
import io.github.computerdaddyguy.jfiletreeprettyprinter.PrettyPrintOptions.TreeFormat;
4+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.TreeFormats;
55

66
public class FileTreeFormat {
77

88
public static void main(String[] args) {
99
var prettyPrinter = FileTreePrettyPrinter.builder()
10-
.customizeOptions(options -> options.withTreeFormat(TreeFormat.CLASSIC_ASCII))
10+
.customizeOptions(options -> options.withTreeFormat(TreeFormats.CLASSIC_ASCII))
1111
.build();
1212
var tree = prettyPrinter.prettyPrint("src/example/resources/tree_format");
1313
System.out.println(tree);

src/example/java/io/github/computerdaddyguy/jfiletreeprettyprinter/example/Filtering.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.computerdaddyguy.jfiletreeprettyprinter.example;
22

33
import io.github.computerdaddyguy.jfiletreeprettyprinter.FileTreePrettyPrinter;
4-
import io.github.computerdaddyguy.jfiletreeprettyprinter.PathMatchers;
4+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.PathMatchers;
55

66
public class Filtering {
77

src/example/java/io/github/computerdaddyguy/jfiletreeprettyprinter/example/LineExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.github.computerdaddyguy.jfiletreeprettyprinter.example;
22

33
import io.github.computerdaddyguy.jfiletreeprettyprinter.FileTreePrettyPrinter;
4-
import io.github.computerdaddyguy.jfiletreeprettyprinter.LineExtensions;
5-
import io.github.computerdaddyguy.jfiletreeprettyprinter.PathMatchers;
4+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.LineExtensions;
5+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.PathMatchers;
66
import java.nio.file.Path;
77
import java.util.function.Function;
88

src/example/java/io/github/computerdaddyguy/jfiletreeprettyprinter/example/ProjectStructure.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.github.computerdaddyguy.jfiletreeprettyprinter.example;
22

3-
import io.github.computerdaddyguy.jfiletreeprettyprinter.ChildLimits;
43
import io.github.computerdaddyguy.jfiletreeprettyprinter.FileTreePrettyPrinter;
5-
import io.github.computerdaddyguy.jfiletreeprettyprinter.LineExtensions;
6-
import io.github.computerdaddyguy.jfiletreeprettyprinter.PathMatchers;
7-
import io.github.computerdaddyguy.jfiletreeprettyprinter.PathSorts;
4+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.ChildLimits;
5+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.LineExtensions;
6+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.PathMatchers;
7+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.PathSorts;
88
import java.nio.file.Path;
99
import java.util.Comparator;
1010
import java.util.function.Function;
@@ -56,9 +56,10 @@ public static void main(String[] args) {
5656
*/
5757
var childLimitFunction = ChildLimits.builder()
5858
// Hide all files under renderer and scanner packages
59+
.add(PathMatchers.hasAbsolutePathMatchingGlob("**/io/github/computerdaddyguy/jfiletreeprettyprinter/options"), 0)
5960
.add(PathMatchers.hasAbsolutePathMatchingGlob("**/io/github/computerdaddyguy/jfiletreeprettyprinter/renderer"), 0)
6061
.add(PathMatchers.hasAbsolutePathMatchingGlob("**/io/github/computerdaddyguy/jfiletreeprettyprinter/scanner"), 0)
61-
.add(PathMatchers.hasAbsolutePathMatchingGlob("**/io/github/computerdaddyguy/jfiletreeprettyprinter"), 3)
62+
.add(PathMatchers.hasAbsolutePathMatchingGlob("**/io/github/computerdaddyguy/jfiletreeprettyprinter"), 4)
6263
.build();
6364

6465
/*
@@ -113,22 +114,25 @@ public static void main(String[] args) {
113114
│ └─ 🖼️ project-structure.png // This image
114115
├─ 📂 src/main/java/
115116
│ └─ 📂 io/github/computerdaddyguy/jfiletreeprettyprinter/
117+
│ ├─ 📂 options/
118+
│ │ └─ ...
116119
│ ├─ 📂 renderer/
117120
│ │ └─ ...
118121
│ ├─ 📂 scanner/
119122
│ │ └─ ...
120123
│ ├─ ☕ FileTreePrettyPrinter.java // Main entry point
121124
│ └─ ...
122-
├─ 🗺️ CHANGELOG.md
123-
├─ 📖 CONTRIBUTING.md
124-
├─ 📄 LICENSE
125-
├─ 📖 README.md // You're reading at this!
125+
├─ 🆕 CHANGELOG.md
126+
├─ 🤝 CONTRIBUTING.md
127+
├─ ⚖️ LICENSE
128+
├─ 📘 README.md // You're reading at this!
126129
├─ 🗺️ ROADMAP.md
127130
├─ 🛡️ SECURITY.md
128-
├─ 🏗️ pom.xml
129-
├─ 📖 release_process.md
131+
├─ 🛠️ pom.xml
132+
├─ 📝 release_process.md
130133
└─ 📜 runMutationTests.sh
131134
135+
132136
*/
133137
}
134138

src/example/java/io/github/computerdaddyguy/jfiletreeprettyprinter/example/Sorting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.computerdaddyguy.jfiletreeprettyprinter.example;
22

33
import io.github.computerdaddyguy.jfiletreeprettyprinter.FileTreePrettyPrinter;
4-
import io.github.computerdaddyguy.jfiletreeprettyprinter.PathSorts;
4+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.PathSorts;
55

66
public class Sorting {
77

src/main/java/io/github/computerdaddyguy/jfiletreeprettyprinter/FileTreePrettyPrinter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.computerdaddyguy.jfiletreeprettyprinter;
22

3+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.PrettyPrintOptions;
34
import java.io.UncheckedIOException;
45
import java.nio.file.Path;
56
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)