bunosh 0.1.5 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/COMPLETION.md ADDED
@@ -0,0 +1,214 @@
1
+ # Shell Completion for Bunosh
2
+
3
+ Bunosh supports auto-completion for bash, zsh, and fish shells. This allows you to:
4
+
5
+ - **Tab-complete** command names
6
+ - **Auto-suggest** available tasks from your Bunoshfile.js
7
+ - **Complete** special commands like `init`, `completion`, `edit`
8
+
9
+ ## Installation
10
+
11
+ ### 🚀 Auto-Setup (Recommended)
12
+
13
+ The easiest way to enable completion:
14
+
15
+ ```bash
16
+ bunosh setup-completion
17
+ ```
18
+
19
+ This command will:
20
+ - **Auto-detect your shell** (bash, zsh, or fish)
21
+ - **Generate the completion script** for your shell
22
+ - **Install it in the correct location**
23
+ - **Update your shell config** (for bash/zsh)
24
+ - **Provide next steps** for activation
25
+
26
+ **Example output for Fish:**
27
+ ```bash
28
+ $ bunosh setup-completion
29
+ 🐚 Detected shell: fish
30
+
31
+ 🔧 Installing completion...
32
+ ✅ Completion installed: /home/user/.config/fish/completions/bunosh.fish
33
+ 🐟 Fish completion is ready! No restart needed.
34
+
35
+ 🎯 Test completion by typing: bunosh <TAB>
36
+ ```
37
+
38
+ **Example output for Bash:**
39
+ ```bash
40
+ $ bunosh setup-completion
41
+ 🐚 Detected shell: bash
42
+
43
+ 🔧 Installing completion...
44
+ ✅ Completion installed: /home/user/.bunosh-completion.bash
45
+ 📝 Updated shell config: /home/user/.bashrc
46
+
47
+ 💡 Restart your terminal or run:
48
+ source ~/.bashrc
49
+
50
+ 🎯 Test completion by typing: bunosh <TAB>
51
+ ```
52
+
53
+ **Options:**
54
+ ```bash
55
+ # Force reinstall (overwrite existing)
56
+ bunosh setup-completion --force
57
+
58
+ # Specify shell manually
59
+ bunosh setup-completion --shell fish
60
+ bunosh setup-completion --shell bash
61
+ bunosh setup-completion --shell zsh
62
+ ```
63
+
64
+ ### Manual Setup
65
+
66
+ If you prefer manual setup, generate the completion script for your shell:
67
+
68
+ ```bash
69
+ # For Bash
70
+ bunosh completion bash > ~/.bunosh-completion.bash
71
+
72
+ # For Zsh
73
+ bunosh completion zsh > ~/.bunosh-completion.zsh
74
+
75
+ # For Fish
76
+ bunosh completion fish > ~/.config/fish/completions/bunosh.fish
77
+ ```
78
+
79
+ ### 2. Enable Completion
80
+
81
+ #### Bash
82
+
83
+ Add to your `~/.bashrc` or `~/.bash_profile`:
84
+
85
+ ```bash
86
+ # Load bunosh completion
87
+ if [ -f ~/.bunosh-completion.bash ]; then
88
+ source ~/.bunosh-completion.bash
89
+ fi
90
+ ```
91
+
92
+ Then reload your shell:
93
+ ```bash
94
+ source ~/.bashrc
95
+ ```
96
+
97
+ #### Zsh
98
+
99
+ Add to your `~/.zshrc`:
100
+
101
+ ```zsh
102
+ # Load bunosh completion
103
+ if [ -f ~/.bunosh-completion.zsh ]; then
104
+ source ~/.bunosh-completion.zsh
105
+ fi
106
+ ```
107
+
108
+ Then reload your shell:
109
+ ```bash
110
+ source ~/.zshrc
111
+ ```
112
+
113
+ #### Fish
114
+
115
+ Fish will automatically load completions from `~/.config/fish/completions/`. No additional setup required after copying the file.
116
+
117
+ ## Usage
118
+
119
+ Once installed, you can use tab completion:
120
+
121
+ ```bash
122
+ # Tab complete commands
123
+ bunosh <TAB>
124
+ # Shows: build, deploy, test, clean, etc.
125
+
126
+ # Tab complete specific commands
127
+ bunosh dep<TAB>
128
+ # Completes to: deploy
129
+
130
+ # Tab complete completion command
131
+ bunosh completion <TAB>
132
+ # Shows: bash zsh fish
133
+
134
+ # Tab complete special commands
135
+ bunosh <TAB>
136
+ # Shows all commands including: init, edit, export:scripts, completion
137
+ ```
138
+
139
+ ## How It Works
140
+
141
+ Bunosh completion works by:
142
+
143
+ 1. **Parsing your Bunoshfile.js** to extract exported function names
144
+ 2. **Converting function names** to command format (camelCase → kebab:case)
145
+ 3. **Reading JSDoc comments** for command descriptions
146
+ 4. **Generating shell-specific** completion scripts
147
+
148
+ ## Examples
149
+
150
+ With a Bunoshfile.js like:
151
+
152
+ ```javascript
153
+ /**
154
+ * Builds the project
155
+ */
156
+ export function build() { /* ... */ }
157
+
158
+ /**
159
+ * Deploys to environment
160
+ */
161
+ export function deployToStaging() { /* ... */ }
162
+ ```
163
+
164
+ You get completion for:
165
+ - `build` - Builds the project
166
+ - `deploy:to-staging` - Deploys to environment
167
+
168
+ ## Updating Completions
169
+
170
+ When you add new tasks to your Bunoshfile.js, regenerate the completion script:
171
+
172
+ ```bash
173
+ bunosh completion bash > ~/.bunosh-completion.bash
174
+ source ~/.bashrc
175
+ ```
176
+
177
+ ## Troubleshooting
178
+
179
+ ### Completion Not Working
180
+
181
+ 1. **Check shell**: Make sure you're using a supported shell (bash, zsh, fish)
182
+ 2. **Verify script**: Run `bunosh completion bash` to see if it generates output
183
+ 3. **Check source**: Ensure completion script is sourced in your shell config
184
+ 4. **Reload shell**: Restart terminal or run `source ~/.bashrc`
185
+
186
+ ### Missing Commands
187
+
188
+ 1. **Check Bunoshfile**: Ensure functions are properly exported
189
+ 2. **Regenerate**: Run completion generation again
190
+ 3. **Syntax**: Verify JSDoc comments are properly formatted
191
+
192
+ ### Error Messages
193
+
194
+ ```bash
195
+ # If you see "Unsupported shell"
196
+ bunosh completion fish # Use: bash, zsh, or fish
197
+
198
+ # If completion script is empty
199
+ # Check that Bunoshfile.js exists and has exported functions
200
+ ```
201
+
202
+ ## Advanced
203
+
204
+ ### Custom Completion
205
+
206
+ The completion system automatically detects:
207
+ - Exported functions → commands
208
+ - JSDoc comments → descriptions
209
+ - Function arguments → parameter completion
210
+ - npm scripts → `npm:*` commands
211
+
212
+ ### Multiple Bunoshfiles
213
+
214
+ Completion works with the Bunoshfile.js in your current directory. For different projects, regenerate completion when switching contexts or use project-specific aliases.