@telosh/filetree
v1.0.0
Published
A command-line tool to display directory tree structure
Readme
@telosh/filetree
A command-line tool to display the file tree of a specified directory.
Features
- Display directory structure in a tree format
- Customizable depth level
- File and directory icons support
- File metadata display (size, last modified date)
- Gitignore integration
- Markdown output support
- Customizable exclusions
- Size unit conversion
Installation
Install the package globally using npm:
npm install -g @telosh/filetreeUsage
filetree [dirPath] [options]dirPath: The directory path to display the tree structure for. Defaults to the current directory (.).
Options
| Option | Alias | Description | Default |
|-----------------------|-------|--------------------------------------------------------------------------|---------------------------|
| --level <depth> | -L | Descend only <depth> levels in the directory tree. | Infinity |
| --output <filepath> | -o | Write output to a file in Markdown format. | Output to console |
| --exclude <dirs> | -e | Comma-separated list of directory names to exclude. | node_modules,.git |
| --icons | -i | Display icons for files and directories. | Off |
| --metadata | -m | Display file metadata (size, last modified date). | Off |
| --size-only | | Display only file size in metadata (requires --metadata). | Off |
| --size-unit <unit> | | Specify size unit for metadata (B, KB, MB, GB). | B |
| --use-gitignore | | Automatically exclude files and directories found in .gitignore. | Off |
| --version | | Display the version number. | |
| --help | | Display help for the command. | |
Examples
Display the tree structure of the current directory:
filetreeDisplay the tree structure of a specific directory (e.g.,
src):filetree srcDisplay the tree structure up to 2 levels deep:
filetree -L 2Exclude
node_modulesanddistdirectories:filetree -e node_modules,distSave the output to a Markdown file (e.g.,
tree.md):filetree -o tree.mdDisplay the tree structure with icons:
filetree -iDisplay the tree structure with metadata (size and last modified date):
filetree -mDisplay the tree structure with only file sizes in KB:
filetree -m --size-only --size-unit KBDisplay the tree structure, excluding files and directories from
.gitignore:filetree --use-gitignore
Development
Prerequisites
- Node.js >= 18.0.0
- npm
Setup
- Clone the repository:
git clone https://github.com/telosh/fileTree.git
cd fileTree- Install dependencies:
npm install- Build the project:
npm run buildTesting
Run tests:
npm testContributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Version History
- 1.0.0
- Initial stable release
- Complete feature set
- Improved error handling
- Full documentation
License
This project is licensed under the MIT License. See the LICENSE file for details.
