A command-line tool to display directory tree structure
npm install @telosh/filetreebash
npm install -g @telosh/filetree
`
Usage
`bash
filetree [dirPath] [options]
`
- dirPath: The directory path to display the tree structure for. Defaults to the current directory (.).
Options
| Option | Alias | Description | Default |
|-----------------------|-------|--------------------------------------------------------------------------|---------------------------|
| --level | -L | Descend only levels in the directory tree. | Infinity |
| --output | -o | Write output to a file in Markdown format. | Output to console |
| --exclude | -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 | | 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
1. Display the tree structure of the current directory:
`bash
filetree
`
2. Display the tree structure of a specific directory (e.g., src):
`bash
filetree src
`
3. Display the tree structure up to 2 levels deep:
`bash
filetree -L 2
`
4. Exclude node_modules and dist directories:
`bash
filetree -e node_modules,dist
`
5. Save the output to a Markdown file (e.g., tree.md):
`bash
filetree -o tree.md
`
6. Display the tree structure with icons:
`bash
filetree -i
`
7. Display the tree structure with metadata (size and last modified date):
`bash
filetree -m
`
8. Display the tree structure with only file sizes in KB:
`bash
filetree -m --size-only --size-unit KB
`
9. Display the tree structure, excluding files and directories from .gitignore:
`bash
filetree --use-gitignore
`
Development
$3
- Node.js >= 18.0.0
- npm
$3
1. Clone the repository:
`bash
git clone https://github.com/telosh/fileTree.git
cd fileTree
`
2. Install dependencies:
`bash
npm install
`
3. Build the project:
`bash
npm run build
`
$3
Run tests:
`bash
npm test
`
$3
1. Fork the repository
2. Create your feature branch (git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)