Lazza / RecuperaBit

A tool for forensic file system reconstruction.
GNU General Public License v3.0
517 stars 73 forks source link

A better tree command #109

Open s0lst1ce opened 2 years ago

s0lst1ce commented 2 years ago

The tree command is really great, especially when you only want to restore select parts of your partition. However the way it's displayed is a little subpar in my opinion. I think it'd be much better if the data was displayed (or had an option to) as follows:

tracking v0.1.0 (/home/toude/tracking)
├── anyhow v1.0.58
├── oauth2 v4.2.0
│   ├── base64 v0.13.0
│   ├── chrono v0.4.19
│   │   ├── libc v0.2.126
│   │   ├── num-integer v0.1.45
│   │   │   └── num-traits v0.2.15
│   │   │       [build-dependencies]
│   │   │       └── autocfg v1.1.0
│   │   │   [build-dependencies]
│   │   │   └── autocfg v1.1.0
│   │   ├── num-traits v0.2.15 (*)
│   │   └── serde v1.0.137
│   │       └── serde_derive v1.0.137 (proc-macro)
│   │           ├── proc-macro2 v1.0.40
│   │           │   └── unicode-ident v1.0.1
│   │           ├── quote v1.0.20
│   │           │   └── proc-macro2 v1.0.40 (*)
│   │           └── syn v1.0.98
│   │               ├── proc-macro2 v1.0.40 (*)
│   │               ├── quote v1.0.20 (*)
│   │               └── unicode-ident v1.0.1
│   ├── http v0.2.8
│   │   ├── bytes v1.1.0
│   │   ├── fnv v1.0.7
│   │   └── itoa v1.0.2
│   ├── rand v0.8.5
│   │   ├── libc v0.2.126
│   │   ├── rand_chacha v0.3.1
│   │   │   ├── ppv-lite86 v0.2.16
│   │   │   └── rand_core v0.6.3
│   │   │       └── getrandom v0.2.7
│   │   │           ├── cfg-if v1.0.0
│   │   │           └── libc v0.2.126
│   │   └── rand_core v0.6.3 (*)
│   ├── reqwest v0.11.11
│   │   ├── base64 v0.13.0
│   │   ├── bytes v1.1.0
│   │   ├── encoding_rs v0.8.31
│   │   │   └── cfg-if v1.0.0
│   │   ├── futures-core v0.3.21
│   │   ├── futures-util v0.3.21
│   │   │   ├── futures-core v0.3.21
│   │   │   ├── futures-io v0.3.21
│   │   │   ├── futures-task v0.3.21
│   │   │   ├── memchr v2.5.0
│   │   │   ├── pin-project-lite v0.2.9
│   │   │   ├── pin-utils v0.1.0
│   │   │   └── slab v0.4.6
│   │   ├── h2 v0.3.13
│   │   │   ├── bytes v1.1.0
│   │   │   ├── fnv v1.0.7
│   │   │   ├── futures-core v0.3.21
│   │   │   ├── futures-sink v0.3.21
│   │   │   ├── futures-util v0.3.21 (*)
│   │   │   ├── http v0.2.8 (*)
│   │   │   ├── indexmap v1.9.1
│   │   │   │   └── hashbrown v0.12.1
│   │   │   │   [build-dependencies]
│   │   │   │   └── autocfg v1.1.0
│   │   │   ├── slab v0.4.6
│   │   │   ├── tokio v1.19.2
│   │   │   │   ├── bytes v1.1.0
│   │   │   │   ├── libc v0.2.126
│   │   │   │   ├── memchr v2.5.0
│   │   │   │   ├── mio v0.8.4
│   │   │   │   │   ├── libc v0.2.126
│   │   │   │   │   └── log v0.4.17
│   │   │   │   │       └── cfg-if v1.0.0
│   │   │   │   ├── num_cpus v1.13.1
│   │   │   │   │   └── libc v0.2.126
│   │   │   │   ├── once_cell v1.12.0
│   │   │   │   ├── parking_lot v0.12.1
│   │   │   │   │   ├── lock_api v0.4.7
│   │   │   │   │   │   └── scopeguard v1.1.0
│   │   │   │   │   │   [build-dependencies]
│   │   │   │   │   │   └── autocfg v1.1.0
│   │   │   │   │   └── parking_lot_core v0.9.3
│   │   │   │   │       ├── cfg-if v1.0.0
│   │   │   │   │       ├── libc v0.2.126
│   │   │   │   │       └── smallvec v1.8.1
│   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   ├── signal-hook-registry v1.4.0
│   │   │   │   │   └── libc v0.2.126
│   │   │   │   ├── socket2 v0.4.4
│   │   │   │   │   └── libc v0.2.126
│   │   │   │   └── tokio-macros v1.8.0 (proc-macro)
│   │   │   │       ├── proc-macro2 v1.0.40 (*)
│   │   │   │       ├── quote v1.0.20 (*)
│   │   │   │       └── syn v1.0.98 (*)
│   │   │   ├── tokio-util v0.7.3
│   │   │   │   ├── bytes v1.1.0
│   │   │   │   ├── futures-core v0.3.21
│   │   │   │   ├── futures-sink v0.3.21
│   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   ├── tokio v1.19.2 (*)
│   │   │   │   └── tracing v0.1.35
│   │   │   │       ├── cfg-if v1.0.0
│   │   │   │       ├── pin-project-lite v0.2.9
│   │   │   │       └── tracing-core v0.1.28
│   │   │   │           └── once_cell v1.12.0
│   │   │   └── tracing v0.1.35 (*)
│   │   ├── http v0.2.8 (*)
│   │   ├── http-body v0.4.5
│   │   │   ├── bytes v1.1.0
│   │   │   ├── http v0.2.8 (*)
│   │   │   └── pin-project-lite v0.2.9
│   │   ├── hyper v0.14.19
│   │   │   ├── bytes v1.1.0
│   │   │   ├── futures-channel v0.3.21
│   │   │   │   └── futures-core v0.3.21
│   │   │   ├── futures-core v0.3.21
│   │   │   ├── futures-util v0.3.21 (*)
│   │   │   ├── h2 v0.3.13 (*)
│   │   │   ├── http v0.2.8 (*)
│   │   │   ├── http-body v0.4.5 (*)
│   │   │   ├── httparse v1.7.1
│   │   │   ├── httpdate v1.0.2
│   │   │   ├── itoa v1.0.2
│   │   │   ├── pin-project-lite v0.2.9
│   │   │   ├── socket2 v0.4.4 (*)
│   │   │   ├── tokio v1.19.2 (*)
│   │   │   ├── tower-service v0.3.2
│   │   │   ├── tracing v0.1.35 (*)
│   │   │   └── want v0.3.0
│   │   │       ├── log v0.4.17 (*)
│   │   │       └── try-lock v0.2.3
│   │   ├── hyper-rustls v0.23.0
│   │   │   ├── http v0.2.8 (*)
│   │   │   ├── hyper v0.14.19 (*)
│   │   │   ├── rustls v0.20.6
│   │   │   │   ├── log v0.4.17 (*)
│   │   │   │   ├── ring v0.16.20
│   │   │   │   │   ├── libc v0.2.126
│   │   │   │   │   ├── once_cell v1.12.0
│   │   │   │   │   ├── spin v0.5.2
│   │   │   │   │   └── untrusted v0.7.1
│   │   │   │   │   [build-dependencies]
│   │   │   │   │   └── cc v1.0.73
│   │   │   │   ├── sct v0.7.0
│   │   │   │   │   ├── ring v0.16.20 (*)
│   │   │   │   │   └── untrusted v0.7.1
│   │   │   │   └── webpki v0.22.0
│   │   │   │       ├── ring v0.16.20 (*)
│   │   │   │       └── untrusted v0.7.1
│   │   │   ├── tokio v1.19.2 (*)
│   │   │   └── tokio-rustls v0.23.4
│   │   │       ├── rustls v0.20.6 (*)
│   │   │       ├── tokio v1.19.2 (*)
│   │   │       └── webpki v0.22.0 (*)
│   │   ├── hyper-tls v0.5.0
│   │   │   ├── bytes v1.1.0
│   │   │   ├── hyper v0.14.19 (*)
│   │   │   ├── native-tls v0.2.10
│   │   │   │   ├── log v0.4.17 (*)
│   │   │   │   ├── openssl v0.10.40
│   │   │   │   │   ├── bitflags v1.3.2
│   │   │   │   │   ├── cfg-if v1.0.0
│   │   │   │   │   ├── foreign-types v0.3.2
│   │   │   │   │   │   └── foreign-types-shared v0.1.1
│   │   │   │   │   ├── libc v0.2.126
│   │   │   │   │   ├── once_cell v1.12.0
│   │   │   │   │   ├── openssl-macros v0.1.0 (proc-macro)
│   │   │   │   │   │   ├── proc-macro2 v1.0.40 (*)
│   │   │   │   │   │   ├── quote v1.0.20 (*)
│   │   │   │   │   │   └── syn v1.0.98 (*)
│   │   │   │   │   └── openssl-sys v0.9.74
│   │   │   │   │       └── libc v0.2.126
│   │   │   │   │       [build-dependencies]
│   │   │   │   │       ├── autocfg v1.1.0
│   │   │   │   │       ├── cc v1.0.73
│   │   │   │   │       └── pkg-config v0.3.25
│   │   │   │   ├── openssl-probe v0.1.5
│   │   │   │   └── openssl-sys v0.9.74 (*)
│   │   │   ├── tokio v1.19.2 (*)
│   │   │   └── tokio-native-tls v0.3.0
│   │   │       ├── native-tls v0.2.10 (*)
│   │   │       └── tokio v1.19.2 (*)
│   │   ├── ipnet v2.5.0
│   │   ├── lazy_static v1.4.0
│   │   ├── log v0.4.17 (*)
│   │   ├── mime v0.3.16
│   │   ├── mime_guess v2.0.4
│   │   │   ├── mime v0.3.16
│   │   │   └── unicase v2.6.0
│   │   │       [build-dependencies]
│   │   │       └── version_check v0.9.4
│   │   │   [build-dependencies]
│   │   │   └── unicase v2.6.0 (*)
│   │   ├── native-tls v0.2.10 (*)
│   │   ├── percent-encoding v2.1.0
│   │   ├── pin-project-lite v0.2.9
│   │   ├── rustls v0.20.6 (*)
│   │   ├── rustls-pemfile v1.0.0
│   │   │   └── base64 v0.13.0
│   │   ├── serde v1.0.137 (*)
│   │   ├── serde_urlencoded v0.7.1
│   │   │   ├── form_urlencoded v1.0.1
│   │   │   │   ├── matches v0.1.9
│   │   │   │   └── percent-encoding v2.1.0
│   │   │   ├── itoa v1.0.2
│   │   │   ├── ryu v1.0.10
│   │   │   └── serde v1.0.137 (*)
│   │   ├── tokio v1.19.2 (*)
│   │   ├── tokio-native-tls v0.3.0 (*)
│   │   ├── tokio-rustls v0.23.4 (*)
│   │   ├── tower-service v0.3.2
│   │   ├── url v2.2.2
│   │   │   ├── form_urlencoded v1.0.1 (*)
│   │   │   ├── idna v0.2.3
│   │   │   │   ├── matches v0.1.9
│   │   │   │   ├── unicode-bidi v0.3.8
│   │   │   │   └── unicode-normalization v0.1.20
│   │   │   │       └── tinyvec v1.6.0
│   │   │   │           └── tinyvec_macros v0.1.0
│   │   │   ├── matches v0.1.9
│   │   │   ├── percent-encoding v2.1.0
│   │   │   └── serde v1.0.137 (*)
│   │   └── webpki-roots v0.22.3
│   │       └── webpki v0.22.0 (*)
│   ├── serde v1.0.137 (*)
│   ├── serde_json v1.0.81
│   │   ├── itoa v1.0.2
│   │   ├── ryu v1.0.10
│   │   └── serde v1.0.137 (*)
│   ├── serde_path_to_error v0.1.7
│   │   └── serde v1.0.137 (*)
│   ├── sha2 v0.10.2
│   │   ├── cfg-if v1.0.0
│   │   ├── cpufeatures v0.2.2
│   │   └── digest v0.10.3
│   │       ├── block-buffer v0.10.2
│   │       │   └── generic-array v0.14.5
│   │       │       └── typenum v1.15.0
│   │       │       [build-dependencies]
│   │       │       └── version_check v0.9.4
│   │       └── crypto-common v0.1.3
│   │           ├── generic-array v0.14.5 (*)
│   │           └── typenum v1.15.0
│   ├── thiserror v1.0.31
│   │   └── thiserror-impl v1.0.31 (proc-macro)
│   │       ├── proc-macro2 v1.0.40 (*)
│   │       ├── quote v1.0.20 (*)
│   │       └── syn v1.0.98 (*)
│   └── url v2.2.2 (*)
├── reqwest v0.11.11 (*)
├── tokio v1.19.2 (*)
└── url v2.2.2 (*)

This is an example of what cargo tree produces, which I find much easier to follow.

If you think this would be better suited for an external tool instead of making it the default, maybe we could provide such a tool alongside the main.py program?

s0lst1ce commented 2 years ago

This looks even better with ligatures (ex: FiraCode font). Here's what a part of the previous example looks like: image

s0lst1ce commented 2 years ago

The relevant part of the tree command from cargo seems to be here https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/tree/graph.rs