A C++ implementation of the tree
command for Windows and Linux environments.
cpp_tree
is a command-line utility that displays the directory structure of a given path in a tree-like format. It mimics the functionality of the tree
command found in CMD (Windows) and Linux terminals.
- Display directory structure in a tree format
- Option to show or hide files
- Cross-platform compatibility (Windows and Linux)
To build and run this project, you'll need:
- C++17 compatible compiler
- CMake (3.10 or higher)
- MSYS2 (for Windows users)
-
Clone the repository:
git clone https://github.com/MohammedHamza0631/cpp_tree.git cd cpp_tree
-
Create a build directory and navigate to it:
mkdir build cd build
-
Generate the build files with CMake:
cmake ..
-
Build the project:
cmake --build .
After building the project, you can run the cpp_tree
executable from the command line:
./cpp_tree [path] [/F]
[path]
: Optional. The directory path to display. If not provided, the current directory will be used./F
: Optional. Include this flag to display files in addition to directories.
-
Display the structure of the current directory (directories only):
./cpp_tree
-
Display the structure of a specific directory (directories only):
./cpp_tree "D:\Development\MongoDB"
Output:
D:\Development\MongoDB |-- CRUD |-- Exercise | |-- models | `-- views `-- mongoose `-- models
-
Display the structure of a specific directory, including files:
./cpp_tree "D:\Development\MongoDB" /F
Output:
D:\Development\MongoDB |-- CRUD | |-- create.js | `-- Crud.mongodb.js |-- Exercise | |-- main.js | |-- models | | `-- Employee.js | `-- views | `-- index.ejs `-- mongoose |-- main.js `-- models `-- Todo.js
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.