|
1 |
| -# PrintLayout |
| 1 | +# PrintLayout 🌳 |
2 | 2 |
|
3 |
| - |
| 3 | + |
4 | 4 |
|
5 |
| -PrintLayout is a command-line tool that prints the directory structure of a specified folder in a tree format. It is designed to be simple, fast, and customizable. |
| 5 | +PrintLayout is a powerful, customizable command-line tool for printing directory structures in a tree format. Built with Go for simplicity and performance, it offers extensive features for visualizing and exploring file systems. |
6 | 6 |
|
7 |
| -## Installation |
| 7 | +## 🚀 Installation |
8 | 8 |
|
9 |
| -### Option 1: Download Pre-Built Binaries |
| 9 | +### Pre-Built Binaries |
10 | 10 |
|
11 |
| -Download the pre-built binary for your operating system from the [Releases page](https://github.com/Ahmedhossamdev/PrintLayout/releases). |
| 11 | +Download the appropriate binary for your operating system from the [Releases page](https://github.com/Ahmedhossamdev/PrintLayout/releases). |
12 | 12 |
|
13 | 13 | #### Linux/macOS
|
| 14 | +```bash |
| 15 | +# Download binary |
| 16 | +chmod +x pr-linux-amd64 |
| 17 | +sudo mv pr-linux-amd64 /usr/local/bin/pr |
14 | 18 |
|
15 |
| -1. Download the binary for your platform (e.g., `printlayout-linux-amd64` or `printlayout-darwin-amd64`). |
16 |
| -2. Make the binary executable: |
17 |
| -3. |
18 |
| - ```bash |
19 |
| - chmod +x printlayout-linux-amd64 |
20 |
| - ``` |
21 |
| -4. Move the binary to a directory in your `PATH` (e.g., `/usr/local/bin`): |
22 |
| -5. |
23 |
| - ```bash |
24 |
| - sudo mv printlayout-linux-amd64 /usr/local/bin/printlayout |
25 |
| - ``` |
26 |
| -6. Run the program: |
27 |
| -7. |
28 |
| - ```bash |
29 |
| - pr -dir /path/to/your/folder or pr to print the current dir |
30 |
| - ``` |
| 19 | +# Run |
| 20 | +pr -dir /path/to/your/folder |
| 21 | +``` |
31 | 22 |
|
32 | 23 | #### Windows
|
| 24 | +1. Download `pr-windows-amd64.exe` |
| 25 | +2. Move to a directory in your `PATH` |
33 | 26 |
|
34 |
| -1. Download the binary for your platform (e.g., `printlayout-windows-amd64.exe`). |
35 |
| -2. Move the binary to a directory in your `PATH` (e.g., `C:\Windows\System32`). |
| 27 | +## 📋 Command-Line Flags |
36 | 28 |
|
37 |
| -## Usage |
| 29 | +### Basic Flags |
38 | 30 |
|
39 |
| -### Print the Directory Structure |
| 31 | +| Flag | Description | Default | Example | |
| 32 | +|------|-------------|---------|---------| |
| 33 | +| `--dir` | Specify directory to print | Current directory | `pr --dir /path/to/folder` | |
| 34 | +| `--ext` | Filter files by extension | All files | `pr --ext .go` | |
| 35 | +| `--output` | Save output to file | Terminal output | `pr --output output.txt` | |
| 36 | +| `--no-color` | Disable colored output | Colors enabled | `pr --no-color` | |
40 | 37 |
|
41 |
| -To print the directory structure of the current folder: |
| 38 | +### Sorting Flags |
42 | 39 |
|
43 |
| -```bash |
44 |
| -pr |
45 |
| -``` |
| 40 | +| Flag | Description | Options | Default | Example | |
| 41 | +|------|-------------|---------|---------|---------| |
| 42 | +| `--sort-by` | Sort criteria | `name`, `size`, `time` | `name` | `pr --sort-by size` | |
| 43 | +| `--order` | Sorting order | `asc`, `desc` | `asc` | `pr --sort-by time --order desc` | |
46 | 44 |
|
47 |
| -To print the directory structure of a specific folder:**** |
| 45 | +### Exclusion Flags |
48 | 46 |
|
49 |
| -```bash |
50 |
| -pr -dir /path/to/your/folder |
51 |
| -``` |
| 47 | +| Flag | Description | Default | Example | |
| 48 | +|------|-------------|---------|---------| |
| 49 | +| `--exclude` | Exclude files/dirs matching pattern | No exclusions | `pr --exclude "*.log"` | |
52 | 50 |
|
53 |
| -To print the directory structure and filter by a specific file extension (e.g., .go, .js, .rb): |
| 51 | +### Output Format Flags |
54 | 52 |
|
55 |
| -```bash |
56 |
| -pr -ext .js |
57 |
| -``` |
| 53 | +| Flag | Description | Options | Default | Example | |
| 54 | +|------|-------------|---------|---------|---------| |
| 55 | +| `--format` | Output format | `text`, `json`, `xml`, `yaml` | `text` | `pr --format json` | |
58 | 56 |
|
59 |
| -To print the directory structure of a specific folder, filter by a specific file extension, and save the output to a file: |
| 57 | +### Color Customization Flags |
60 | 58 |
|
61 |
| -```bash |
62 |
| -pr -dir /path/to/your/folder -ext .rb -output output.txt |
63 |
| -``` |
| 59 | +| Flag | Description | Options | Default | Example | |
| 60 | +|------|-------------|---------|---------|---------| |
| 61 | +| `--dir-color` | Directory color | `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white` | `blue` | `pr --dir-color green` | |
| 62 | +| `--file-color` | File color | Same as above | `green` | `pr --file-color yellow` | |
| 63 | +| `--exec-color` | Executable file color | Same as above | `red` | `pr --exec-color magenta` | |
64 | 64 |
|
65 |
| -### Example Output |
| 65 | +### Supported Colors (We will add more) |
66 | 66 |
|
67 |
| -```bash |
68 |
| -$ pr -dir /path/to/your/folder |
69 |
| -printLayout/ |
70 |
| -├── cmd/ |
71 |
| -│ └── main.go |
72 |
| -├── go.mod |
73 |
| -├── internal/ |
74 |
| -│ └── utils/ |
75 |
| -│ └── utils.go |
76 |
| -└── pkg/ |
77 |
| - └── printer/ |
78 |
| - ├── printer.go |
79 |
| - └── printer_test.go |
80 |
| -``` |
| 67 | +printLayout supports the following colors for customization: |
81 | 68 |
|
82 |
| -# `pr` Command-Line Flags |
83 |
| - |
84 |
| -## Basic Flags |
85 |
| - |
86 |
| -### `--dir` |
87 |
| -- **Description**: Specifies the directory to print the structure of. |
88 |
| -- **Default**: Current directory (`.`) |
89 |
| -- **Example**: `pr --dir /path/to/your/folder` |
90 |
| - |
91 |
| -### `--ext` |
92 |
| -- **Description**: Filters files by a specific extension (e.g., `.go`, `.js`) |
93 |
| -- **Default**: No filter (all files are included) |
94 |
| -- **Example**: `pr --ext .go` |
95 |
| - |
96 |
| -### `--output` |
97 |
| -- **Description**: Saves the output to a file instead of printing it to the terminal |
98 |
| -- **Default**: Output is printed to the terminal |
99 |
| -- **Example**: `pr --output output.txt` |
100 |
| - |
101 |
| -### `--no-color` |
102 |
| -- **Description**: Disables colored output |
103 |
| -- **Default**: Colors are enabled |
104 |
| -- **Example**: `pr --no-color` |
105 |
| - |
106 |
| -## Sorting Flags |
107 |
| - |
108 |
| -### `--sort-by` |
109 |
| -- **Description**: Specifies the sorting criteria |
110 |
| -- **Options**: |
111 |
| - - `name`: Sort by file/directory name |
112 |
| - - `size`: Sort by file size |
113 |
| - - `time`: Sort by modification time |
114 |
| -- **Default**: `name` |
115 |
| -- **Example**: `pr --sort-by size` |
116 |
| - |
117 |
| -### `--order` |
118 |
| -- **Description**: Specifies the sorting order |
119 |
| -- **Options**: |
120 |
| - - `asc`: Ascending order |
121 |
| - - `desc`: Descending order |
122 |
| -- **Default**: `asc` |
123 |
| -- **Example**: `pr --sort-by time --order desc` |
124 |
| - |
125 |
| -## Exclusion Flags |
126 |
| - |
127 |
| -### `--exclude` |
128 |
| -- **Description**: Excludes files or directories matching the specified pattern (can be used multiple times) |
129 |
| -- **Default**: No exclusions |
130 |
| -- **Example**: `pr --exclude "*.log" --exclude "tmp/*"` |
131 |
| - |
132 |
| -## Output Format Flags |
133 |
| - |
134 |
| -### `--format` |
135 |
| -- **Description**: Specifies the output format |
136 |
| -- **Options**: |
137 |
| - - `text`: Plain text format (default) |
138 |
| - - `json`: JSON format |
139 |
| - - `xml`: XML format |
140 |
| - - `yaml`: YAML format |
141 |
| -- **Default**: `text` |
142 |
| -- **Example**: `pr --format json` |
143 |
| - |
144 |
| -## Color Customization Flags |
145 |
| - |
146 |
| -### `--dir-color` |
147 |
| -- **Description**: Specifies the color for directories |
148 |
| -- **Options**: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white` |
149 |
| -- **Default**: `blue` |
150 |
| -- **Example**: `pr --dir-color green` |
151 |
| - |
152 |
| -### `--file-color` |
153 |
| -- **Description**: Specifies the color for files |
154 |
| -- **Options**: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white` |
155 |
| -- **Default**: `green` |
156 |
| -- **Example**: `pr --file-color yellow` |
157 |
| - |
158 |
| -### `--exec-color` |
159 |
| -- **Description**: Specifies the color for executable files |
160 |
| -- **Options**: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white` |
161 |
| -- **Default**: `red` |
162 |
| -- **Example**: `pr --exec-color magenta` |
163 |
| - |
164 |
| -## Help Flag |
165 |
| - |
166 |
| -### `--help` or `-h` |
167 |
| -- **Description**: Displays the help message with all available flags and usage examples |
168 |
| -- **Example**: `pr --help` |
169 |
| - |
170 |
| -## Combined Flags Example |
| 69 | +- `black` |
| 70 | +- `red` |
| 71 | +- `green` |
| 72 | +- `yellow` |
| 73 | +- `blue` |
| 74 | +- `magenta` |
| 75 | +- `cyan` |
| 76 | +- `white` |
171 | 77 |
|
| 78 | +## 🔍 Basic Examples |
| 79 | + |
| 80 | +### 1. Print the current directory structure |
172 | 81 | ```bash
|
173 |
| -pr --dir /path/to/your/folder --ext .go --sort-by size --order desc --output output.txt --no-color |
| 82 | + pr |
| 83 | +``` |
| 84 | +### 2. Specify a directory to explore |
| 85 | +```bash |
| 86 | +pr --dir ./path/to/project |
174 | 87 | ```
|
175 | 88 |
|
176 |
| -## Development |
177 |
| - |
178 |
| -### Run the Project in Development |
| 89 | +### 3.Combined flags |
| 90 | +```bash |
| 91 | +pr --dir /path/to/project --ext .ts --sort-by size --order desc --exclude "node_modules" --exclude "*.test" --dir-color magenta --file-color cyan --output project_structure.txt |
| 92 | +``` |
179 | 93 |
|
180 |
| -To run the project during development without installing it: |
| 94 | +## 🛠 Development |
181 | 95 |
|
| 96 | +### Run Project |
182 | 97 | ```bash
|
183 | 98 | go run ./cmd/main.go
|
184 | 99 | ```
|
185 | 100 |
|
186 | 101 | ### Run Tests
|
187 |
| - |
188 |
| -To run the tests: |
189 |
| - |
190 | 102 | ```bash
|
191 | 103 | go test -v ./...
|
192 | 104 | ```
|
193 | 105 |
|
194 |
| -### Build the Project |
195 |
| - |
196 |
| -To build the project: |
197 |
| - |
| 106 | +### Build Project |
198 | 107 | ```bash
|
199 | 108 | go build -o printlayout ./cmd/main.go
|
200 | 109 | ```
|
201 | 110 |
|
202 |
| -This will create an executable named printlayout in your project directory. |
203 |
| - |
204 |
| -## Future Improvements (TODOs) |
205 |
| - |
206 |
| -Here are some ideas for future improvements to the project: |
207 |
| - |
208 |
| -1. Advanced Command-Line Options: |
209 |
| - |
210 |
| - - [ ] Add support for limiting the depth of the directory tree (e.g., --depth 2). |
211 |
| - - [ ] an option to include hidden files and directories (e.g., --hidden). |
212 |
| - - [ ] an option to ignore files and directories listed in .gitignore (e.g., --ignore-gitignore). |
213 |
| - |
214 |
| -2. Customizable Output: |
215 |
| - |
216 |
| - - [ ] support for customizing the tree symbols (e.g., --symbols=ascii for ASCII-only output). |
217 |
| - - [x] support for exporting the directory structure to a file (e.g., --output tree.txt). |
218 |
| - |
219 |
| -3. Performance Improvements: |
220 |
| - - [ ] Optimize the directory traversal for large directories. |
221 |
| - - [ ] Add support for parallel processing of directories. |
222 |
| - |
223 |
| -## Contributing |
| 111 | +## 🤝 Contributing |
224 | 112 |
|
225 |
| -Contributions are welcome! If you'd like to contribute, please follow these steps: |
| 113 | +1. Fork the repository |
| 114 | +2. Create a feature branch |
| 115 | +3. Commit changes |
| 116 | +4. Push and submit a pull request |
226 | 117 |
|
227 |
| -1. Fork the repository. |
228 |
| -2. Create a new branch for your feature or bugfix. |
229 |
| -3. Make your changes and write tests if applicable. |
230 |
| -4. Submit a pull request with a detailed description of your changes. |
| 118 | +## 📜 License |
231 | 119 |
|
| 120 | +I don't know about License stuff, but this project made by me |
232 | 121 |
|
233 |
| -## Acknowledgments |
| 122 | +## 🙏 Acknowledgments |
234 | 123 |
|
235 |
| -- Built with Go for simplicity and performance. |
236 |
| -- Inspired by GNU Tree: Incorporating all the features of GNU Tree while innovating with new functionalities to enhance the user experience. |
| 124 | +- Built with Go |
| 125 | +- Inspired by GNU Tree |
0 commit comments