treemk
Version:
A CLI tool to generate project structures from text, JSON templates, file, with boilerplate and git integration
385 lines (304 loc) โข 12.5 kB
Markdown
# ๐ File Detection System - Visual Guide
## ๐ฏ Main Question: Does file need to be in project directory?
**Answer: NO! File can be ANYWHERE!**
## ๐ How It Works (5-Level Search)
```
Developer runs: treemk -i structure.txt -o ./myapp
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Start Search โ
โ for file named: โ
โ "structure.txt" โ
โโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LEVEL 1: ABSOLUTE PATH โ
โ Is it full path like /home/user/...? โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโดโโโโโโ
โ โ
YES NO
โ โ
โ
FOUND โ
Use it! โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LEVEL 2: CURRENT DIRECTORY (pwd) โ
โ Check: /current/working/directory/ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโดโโโโโโ
โ โ
YES NO
โ โ
โ
FOUND โ
Use it! โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LEVEL 3: TREEMK INSTALL DIRECTORY โ
โ Check: /where/treemk/is/installed/ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโดโโโโโโ
โ โ
YES NO
โ โ
โ
FOUND โ
Use it! โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LEVEL 4: COMMON USER FOLDERS โ
โ โ
โ A. ~/Downloads/structure.txt โ
โ B. ~/Documents/structure.txt โ
โ C. ~/Desktop/structure.txt โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโผโโโโโโโโโโ
โ โ โ
Found Found Found
in A in B in C
โ โ โ
โโโโโโฌโโโโโดโโโโโฌโโโโโ
โ โ
โ
FOUND โ
FOUND
Use it! Use it!
โ
NO
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LEVEL 5: NOT FOUND โ
โ โ
โ Show error with helpful tips: โ
โ - Try absolute path โ
โ - Try relative path โ
โ - Put in Downloads/Documents/Desktop โ
โ - Or use --text instead โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
## ๐ Real World Examples
### Example 1: File Downloaded from Email
```bash
# User receives email with structure.txt
# Gmail downloads it to: ~/Downloads/structure.txt
# User is working in their project folder
cd ~/workspace/my-new-api
# User runs treemk with JUST the filename
treemk -i structure.txt -o ./api -b
# What happens:
# โโ Level 1: Not absolute path โ
# โโ Level 2: Not in ~/workspace/my-new-api/ โ
# โโ Level 3: Not in treemk folder โ
# โโ Level 4: Found in ~/Downloads/ โ
#
# Result: โ
Works perfectly!
```
### Example 2: File from Slack/Teams
```bash
# Coworker shares structure file via Slack
# Slack saves to: ~/Downloads/company-api-structure.txt
# You're anywhere on your system
cd /tmp/testing
# Run with just filename
treemk -i company-api-structure.txt -o ./new-api
# What happens:
# โโ Level 1: Not absolute โ
# โโ Level 2: Not in /tmp/testing/ โ
# โโ Level 3: Not in treemk folder โ
# โโ Level 4: Found in ~/Downloads/ โ
#
# Result: โ
It finds it automatically!
```
### Example 3: File in Current Project
```bash
# You created structure.txt in your project
# Location: ~/projects/myapp/structure.txt
cd ~/projects/myapp
treemk -i structure.txt -o ./src
# What happens:
# โโ Level 1: Not absolute path โ
# โโ Level 2: Found in current dir โ
#
# Result: โ
Found immediately!
```
### Example 4: File on Desktop
```bash
# You saved structure.txt on Desktop
# Location: ~/Desktop/structure.txt
# You're in completely different location
cd ~/Documents/random-folder
treemk -i structure.txt -o ./project
# What happens:
# โโ Level 1: Not absolute โ
# โโ Level 2: Not in ~/Documents/random-folder โ
# โโ Level 3: Not in treemk folder โ
# โโ Level 4: Found on Desktop โ
#
# Result: โ
Smart search finds it!
```
### Example 5: File with Full Path
```bash
# You know exact location
treemk -i /home/user/random/deep/nested/folder/structure.txt -o ./app
# What happens:
# โโ Level 1: Absolute path provided โ
#
# Result: โ
Goes directly there!
```
### Example 6: File with Relative Path
```bash
# File is in subfolder of current directory
# Location: ~/projects/myapp/config/structure.txt
cd ~/projects/myapp
treemk -i ./config/structure.txt -o ./src
# OR
treemk -i config/structure.txt -o ./src
# What happens:
# โโ Level 1: Not absolute โ
# โโ Level 2: Found relative to current dir โ
#
# Result: โ
Resolves relative path!
```
## ๐ Detection Priority Table
| Input | Level | Speed | Example |
|-------|-------|-------|---------|
| `/absolute/path/file.txt` | 1 | โก Instant | Direct access |
| `./file.txt` | 2 | โกโก Very Fast | Current directory |
| `../parent/file.txt` | 2 | โกโก Very Fast | Relative path |
| `file.txt` (in current dir) | 2 | โกโก Very Fast | Current directory |
| `file.txt` (in Downloads) | 4 | โกโกโก Fast | Auto-search |
| `file.txt` (in Documents) | 4 | โกโกโก Fast | Auto-search |
| `file.txt` (in Desktop) | 4 | โกโกโก Fast | Auto-search |
| `file.txt` (nowhere) | 5 | โ Error | Helpful message |
## ๐ก Developer Workflows
### Workflow A: Download & Use
```bash
# 1. Download structure from anywhere
# โ Automatically goes to ~/Downloads/
# 2. Open terminal in your project
cd ~/workspace/my-new-project
# 3. Just use the filename!
treemk -i structure.txt -o ./api -b
# โ
Tool finds it in Downloads automatically
```
### Workflow B: Team Shared Structure
```bash
# 1. Team lead puts structure in shared Drive
# You download to ~/Downloads/team-api-structure.txt
# 2. Create new project anywhere
mkdir -p ~/dev/client-api && cd ~/dev/client-api
# 3. Run with just filename
treemk -i team-api-structure.txt -o . -b -g
# โ
Finds in Downloads, creates in current location
```
### Workflow C: Multiple Projects
```bash
# 1. One structure file in Downloads
# ~/Downloads/microservice-template.txt
# 2. Create multiple services
cd ~/projects
mkdir service1 && cd service1
treemk -i microservice-template.txt -o . -b
cd ../
mkdir service2 && cd service2
treemk -i microservice-template.txt -o . -b
cd ../
mkdir service3 && cd service3
treemk -i microservice-template.txt -o . -b
# โ
All three use same file from Downloads
```
## ๐ฏ Common Questions
### Q: "Must I copy file to every project?"
**A: NO!** Keep it in Downloads, Documents, or Desktop. Tool finds it.
### Q: "What if file is in random location?"
**A:** Use absolute path: `treemk -i /path/to/anywhere/file.txt`
### Q: "Can I use without ANY file?"
**A: YES!** Use inline input:
```bash
treemk --text "src/index.js\nREADME.md" -o ./app
```
### Q: "What if I have multiple structure files?"
**A:** Use specific filenames or paths:
```bash
treemk -i api-structure.txt -o ./api
treemk -i frontend-structure.txt -o ./frontend
```
### Q: "Does it search my entire hard drive?"
**A: NO!** Only checks:
- Current directory
- Downloads
- Documents
- Desktop
- Or exact path you provide
### Q: "What if file is on external drive?"
**A:** Use full path: `treemk -i /Volumes/USB/structure.txt`
## ๐ซ What Doesn't Work
### โ Wrong: Random system folders
```bash
# File is in /usr/local/random/
treemk -i structure.txt -o ./app
# Won't find it there! Use absolute path:
treemk -i /usr/local/random/structure.txt -o ./app
```
### โ Wrong: Network drives without mount
```bash
# File is on network drive not mounted
treemk -i structure.txt
# Mount first or download locally
```
### โ
Right: Always works
```bash
# Use absolute path for ANY location
treemk -i /full/path/to/file.txt -o ./app
# Or use inline input (no file needed!)
treemk --text "src/index.js" -o ./app
```
## ๐ Search Speed Comparison
```
Absolute path: 0.001s โก Instant
Current directory: 0.002s โกโก Very Fast
Relative path: 0.002s โกโก Very Fast
Downloads/Docs/Desktop: 0.010s โกโกโก Fast
Not found (all levels): 0.015s (then shows error)
```
All searches complete in **under 20 milliseconds!**
## ๐ Best Practices
### โ
DO:
- Keep structure files in Downloads/Documents/Desktop for easy access
- Use descriptive filenames: `api-structure.txt`, `frontend-template.txt`
- Use absolute paths for files in unusual locations
- Use `--text` or `--json-input` for quick one-offs
### โ DON'T:
- Put files in system directories (`/usr/`, `/var/`, etc.)
- Use same filename for different projects (unless in different folders)
- Expect it to search your entire hard drive
## ๐ง Troubleshooting
### "Cannot find file"
**Check this:**
```bash
# 1. Is file in one of these locations?
ls ~/Downloads/structure.txt
ls ~/Documents/structure.txt
ls ~/Desktop/structure.txt
ls ./structure.txt
# 2. Try with absolute path
treemk -i /full/path/to/structure.txt -o ./app
# 3. Or skip file entirely
treemk --text "src/index.js\nREADME.md" -o ./app
```
## ๐ฏ Summary
**Key Takeaway:** File can be ANYWHERE! Tool is smart enough to find it.
**Search Order:**
1. Absolute path (if you provide full path)
2. Current directory (where you run command)
3. Treemk directory (installation location)
4. Common folders (Downloads, Documents, Desktop)
5. Error with helpful tips (if not found)
**No file needed at all?**
Use: `--text`, `--json-input`, `--template`, or piped input!
**File detection is smart. Your workflow is flexible. Everything just works! ๐**