Having a graphical representation of a tree command

0 votes
asked Oct 17, 2019 in Wanted features by Antonio

The tree command is really useful to show a directory structure... but it would be nicer with an image.

It would be great to have a graphical representation of the `tree` command. You just copy/past the output into a PlantUML diagram, and you get a nice image:

rest-fight/
├── pom.xml
└── src
    ├── main
    │   ├── java
    │   │   └── io
    │   │       └── quarkus

2 Answers

0 votes
answered Oct 17, 2019 by plantuml (295,000 points)
Could you post it some examples of text created by this 'tree' command ?

This will help. Thanks !
commented Oct 18, 2019 by Antonio

.

├── bootstrap.sh

├── mvnw

├── mvnw.cmd

├── pom.xml

├── rest-fight.iml

└── src

    ├── main

    │   ├── docker

    │   │   ├── Dockerfile.jvm

    │   │   └── Dockerfile.native

    │   ├── java

    │   │   └── io

    │   │       └── quarkus

    │   │           └── workshop

    │   │               └── superheroes

    │   │                   └── fight

    │   │                       ├── Fight.java

    │   │                       ├── FightApplication.java

    │   │                       ├── FightResource.java

    │   │                       ├── FightService.java

    │   │                       ├── Fighters.java

    │   │                       ├── client

    │   │                       │   ├── Hero.java

    │   │                       │   ├── HeroService.java

    │   │                       │   ├── Villain.java

    │   │                       │   └── VillainService.java

    │   │                       ├── health

    │   │                       │   ├── DatabaseConnectionHealthCheck.java

    │   │                       │   └── PingFightResourceHealthCheck.java

    │   │                       └── kafka

    │   │                           └── KafkaWriter.java

    │   └── resources

    │       ├── META-INF

    │       │   └── resources

    │       │       └── index.html

    │       ├── application.properties

    │       ├── banner.txt

    │       └── import.sql

    └── test

        └── java

            └── io

                └── quarkus

                    └── workshop

                        └── superheroes

                            └── fight

                                ├── FightResourceTest.java

                                └── client

                                    ├── MockHeroService.java

                                    └── MockVillainService.java

commented Oct 18, 2019 by Antonio

Some flatter structure :

.
├── extension-architecture.puml
├── introduction-physical-architecture.puml
├── messaging-architecture.puml
├── microservices-physical-architecture.puml
├── observability-physical-architecture.puml
├── quarkus-http-architecture.puml
├── rest-physical-architecture.puml
└── style.puml

And the same but from a different root directory (. is replaced by the directory name)

plantuml/
├── extension-architecture.puml
├── introduction-physical-architecture.puml
├── messaging-architecture.puml
├── microservices-physical-architecture.puml
├── observability-physical-architecture.puml
├── quarkus-http-architecture.puml
├── rest-physical-architecture.puml
└── style.puml

commented Oct 22, 2019 by cprn (230 points)

Your example run as explained in my answer.

0 votes
answered Oct 18, 2019 by cprn (230 points)
edited Oct 22, 2019 by cprn

There's a tree widget with Salt:

@startsalt
{
{T
+ World
++ America
+++ Canada
+++ USA
++++ New York
++++ Boston
+++ Mexico
++ Europe
+++ Italy
+++ Germany
++++ Berlin
++ Africa
}
}
@endsalt

With this in mind, would it be sufficient to have a script that translates `tree` output to the correct Salt input? From the top of my head I came up with this:

tree --noreport | sed -e 's/├── \|└── /+ /g' -e 's/│   \|    /+/g' -e 's/^/+/'

You need to fix a space in the 1st line manually, though.

...