0.0.2 • Published 7 months ago

file-tree-cli v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Features

  • šŸŽØ Colorized output (directories in blue, files in cyan)
  • šŸ“ Configurable directory traversal depth
  • šŸ” Multiple filtering options:
    • File extensions
    • Regular expression patterns
    • Hidden files
    • Directories/files only
  • šŸ“Š File size display
  • šŸ“… Last modified dates
  • šŸ”„ Multiple sorting options
  • šŸ’¾ Save output to file
  • ⚔ Performance optimized

Usage

You can run the CLI tool directly using npx without installation:

npx file-tree-cli [options] [directory]

If you prefer to install it globally (optional):

npm install -g file-tree-cli
file-tree [options] [directory]

If no directory is specified, the current directory will be used.

Basic Examples

# Display tree of current directory
npx file-tree-cli

# Display tree of specific directory
npx file-tree-cli /path/to/directory

# Show tree with file sizes
npx file-tree-cli -s

# Show only JavaScript and TypeScript files
npx file-tree-cli --ext js,ts

# Show files modified dates and sizes
npx file-tree-cli -s -m

Advanced Examples

# Show only directories, sorted by name
npx file-tree-cli --dirs-only --sort name

# Show only JavaScript files and their sizes
npx file-tree-cli --ext js -s

# Show tree with custom depth and excluded directories
npx file-tree-cli -d 3 -e "dist,coverage"

# Show all files (including hidden) sorted by size
npx file-tree-cli -a --sort size

# Export tree to a file
npx file-tree-cli -o output.txt

Options

OptionDescriptionDefault
-d, --max-depth <number>Maximum depth to traverseāˆž
-a, --allShow hidden filesfalse
-e, --exclude <items>Comma-separated list of directories to exclude[]
-s, --show-sizeShow file sizesfalse
-m, --modifiedShow last modified datefalse
-f, --pattern <pattern>Filter items by regex patternnull
--ext <extensions>Filter by file extensions (comma-separated)[]
--sort <type>Sort items by: name, size, or datename
-r, --reverseReverse sort orderfalse
--dirs-onlyShow only directoriesfalse
--files-onlyShow only filesfalse
-o, --output <file>Save output to filenull

Output Format

The tool provides a structured view of your directory:

Directory
ā”œā”€ā”€ src
│   ā”œā”€ā”€ index.ts [2.5KB] 2024-01-15
│   └── utils.ts [1.2KB] 2024-01-14
└── package.json [0.8KB] 2024-01-10

Development

  1. Clone the repository:
git clone https://github.com/devxprite/file-tree-cli.git
  1. Install dependencies:
cd file-tree-cli
npm install
  1. Build the project:
npm run build
  1. Test locally:
# Run directly from the project directory
npm start

# Or use npm link for global testing
npm link
tree [options] [directory]

Contributing

Contributions are welcome! Here's how you can contribute:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

0.0.2

7 months ago

0.0.1

7 months ago