Crates.io | tree_gen |
lib.rs | tree_gen |
version | 0.1.3 |
source | src |
created_at | 2024-11-05 12:40:49.791518 |
updated_at | 2024-11-17 03:20:37.453913 |
description | tree_gen is a CLI tool to generate folder structure in ASCII, JSON and visualize folder structure with nice and easy way without leaving your terminal. |
homepage | https://github.com/Kei-K23/tree-gen |
repository | https://github.com/Kei-K23/tree-gen |
max_upload_size | |
id | 1436492 |
size | 64,835 |
tree_gen
is a command-line tool designed to generate visual representations of directory structures in both ASCII and JSON formats. This tool provides an easy way to visualize and explore file hierarchies directly in the terminal. It also supports comparing two directories, filtering files, and customizing the output to suit various needs.
To install tree_gen
globally, you can use cargo
. Just run cargo install tree_gen
in your favorite terminal.
cargo install tree_gen
To use tree_gen
, clone the repository and build the binary using Rust's package manager, Cargo:
cargo build --release
Then you can run tree_gen
from the target/release
directory or add it to your PATH for easy access.
tree_gen <PATH> [OPTIONS]
PATH
: The path of the directory you wish to display or compare.--compare <COMPARE_PATH>
: Compare the specified directory (<PATH>
) with another directory at <COMPARE_PATH>
.-d, --depth <DEPTH>
: Set the maximum depth of the directory tree (default is 10).-e, --extension <EXT>
: Filter output to show only files with the specified file extension.-o, --output <FILE>
: Write the output to a specified file instead of printing to the terminal.--branch-style <STYLE>
: Set the branch style for the tree structure. Options: ascii
, unicode
(default: unicode
).--preview-lines <LINES>
: Display a limited number of preview lines for each file.--date-filter <DATE_FILTER>
: Filter files by date. Format: <before|after|between> <date1>[,<date2>]
.--size-min <SIZE_MIN>
: Set the minimum file size (in bytes) for filtering.--size-max <SIZE_MAX>
: Set the maximum file size (in bytes) for filtering.--include <INCLUDE>
: Include files matching a specific pattern (wildcard or regex).--exclude <EXCLUDE>
: Exclude files matching a specific pattern (wildcard or regex).-i, --ignore-hidden
: Ignore hidden files and folders.--icons
: Display file icons alongside file names.-s, --show-sizes
: Show file sizes next to file names.-j, --json
: Output the directory structure in JSON format.To display the directory structure of the current directory:
tree_gen .
To display a directory tree structure with a maximum depth of 2 levels:
tree_gen . --depth 2
To show only .rs
files in the directory structure:
tree_gen . --extension rs
To save the directory structure to a file named output.txt
:
tree_gen . --output output.txt
To set the branch style to ASCII instead of the default Unicode:
tree_gen . --branch-style ascii
To output the directory structure in JSON format:
tree_gen . --json
To compare two directories (lib
and lib_copy
) and show the differences:
tree_gen lib --compare lib_copy
To show only files larger than 1 KB and smaller than 1 MB:
tree_gen . --size-min 1024 --size-max 1048576
To show files created after January 1, 2023:
tree_gen . --date-filter "after 2023-01-01"
To exclude files matching the pattern *.tmp
:
tree_gen . --exclude "*.tmp"
Or to include only files matching a specific pattern:
tree_gen . --include "*.rs"
-i, --ignore-hidden
: Ignore hidden files and folders.--icons
: Display file icons next to file names.-s, --show-sizes
: Display file sizes alongside file names.--preview-lines <LINES>
: Limit the preview lines for each file to <LINES>
lines.tree_gen
for futures improvements.treegenrc
) for default values for flags like depth
, ignore_hidden
, branch_style
, etc.--interactive
) to allow directory expansion and collapse in the terminal.Contributions are welcome! If you’d like to improve this tool or add new features, please feel free to submit a pull request. (TODO lists for futures improvement already mention above. You can implement TODO lists features or your can create your own new features.).
tree_gen
is open-source software licensed under the MIT License.