@@ -5,10 +5,15 @@ import { run } from "../src/commands/run";
55import { search , list } from "../src/commands/search" ;
66import { info } from "../src/commands/info" ;
77import { edit } from "../src/commands/edit" ;
8+ import { clone } from "../src/commands/clone" ;
89import { open } from "../src/commands/open" ;
10+ import { add } from "../src/commands/add" ;
11+ import { remove } from "../src/commands/remove" ;
12+ import { showConfig } from "../src/commands/config" ;
13+ import { mcp } from "../src/commands/mcp" ;
914import { SnippetCache } from "../src/lib/cache" ;
1015
11- const VERSION = "0.1 .0" ;
16+ const VERSION = "0.2 .0" ;
1217
1318const HELP = `
1419temper - Homebrew for code snippets
@@ -17,32 +22,43 @@ USAGE
1722 temper <command> [options]
1823
1924COMMANDS
20- run <slug> Execute a JavaScript snippet
21- search <query> Search for snippets
22- list List all available snippets
23- info <slug> Show detailed snippet information
24- edit <slug> Download snippet and open in editor
25- open <slug> Open snippet in browser
25+ search [query] Search public gallery (or list all)
26+ list List local snippets
27+ run <slug> Execute a snippet (local first, then public)
28+ info <slug> Show snippet details (local first, then public)
29+ clone <slug> Copy public snippet to local library
30+ edit [slug] Edit local snippet (or open snippets directory)
31+ add <slug> Create new local snippet
32+ remove <slug> Remove local snippet
33+ open <slug> Open public snippet in browser
2634 cache Manage local cache
35+ config Show current configuration
36+ mcp Start MCP server for AI agents
2737
2838OPTIONS
29- -l, --language <lang> Language for info/edit/open (default: javascript)
39+ -l, --language <lang> Language variant (default: javascript)
40+ -f, --force Force overwrite for clone
3041 -h, --help Show help
3142 -v, --version Show version
3243
3344EXAMPLES
34- temper run generate-uuid
45+ temper search "sort array"
46+ temper clone quick-sort
47+ temper edit quick-sort
48+ temper run quick-sort
3549 temper run fibonacci --n=10
3650 echo "hello world" | temper run title-case
37- temper search "sort array"
38- temper info quick-sort
39- temper open generate-uuid
40- temper edit quick-sort -l python
51+ temper list
52+ temper add my-helper
53+
54+ CONFIGURATION
55+ ~/.temper/config.json (or TEMPER_CONFIG)
4156
42- ENVIRONMENT
43- EDITOR Editor for 'temper edit' (default: vim)
44- TEMPER_API_URL API base URL (default: https://tempercode.dev)
45- TEMPER_CACHE_DIR Cache directory (default: ~/.temper/cache)
57+ {
58+ "snippetsDir": "~/Snippets",
59+ "cacheDir": "~/.temper/cache",
60+ "apiBaseUrl": "https://tempercode.dev"
61+ }
4662
4763Learn more: https://tempercode.dev
4864` ;
@@ -92,6 +108,8 @@ async function main() {
92108 type : { type : "string" , short : "t" } ,
93109 limit : { type : "string" } ,
94110 clear : { type : "boolean" } ,
111+ json : { type : "boolean" } ,
112+ force : { type : "boolean" , short : "f" } ,
95113 } ,
96114 allowPositionals : true ,
97115 strict : false , // Allow unknown options (for snippet params like --n=10)
@@ -128,22 +146,19 @@ async function main() {
128146 await run ( slug , {
129147 params : customParams ,
130148 stdin,
149+ json : values . json ,
131150 } ) ;
132151 break ;
133152 }
134153
135154 case "search" : {
136- const query = rest . join ( " " ) ;
137- if ( ! query ) {
138- console . error ( "Usage: temper search <query>" ) ;
139- console . error ( "Example: temper search 'sort array'" ) ;
140- process . exit ( 1 ) ;
141- }
155+ const query = rest . join ( " " ) || undefined ;
142156
143157 await search ( query , {
144158 language : values . language ,
145159 type : values . type ,
146160 limit : values . limit ? parseInt ( values . limit , 10 ) : undefined ,
161+ json : values . json ,
147162 } ) ;
148163 break ;
149164 }
@@ -153,6 +168,21 @@ async function main() {
153168 language : values . language ,
154169 type : values . type ,
155170 limit : values . limit ? parseInt ( values . limit , 10 ) : undefined ,
171+ json : values . json ,
172+ } ) ;
173+ break ;
174+ }
175+
176+ case "clone" : {
177+ if ( ! slug ) {
178+ console . error ( "Usage: temper clone <slug> [-l language]" ) ;
179+ console . error ( "Example: temper clone quick-sort" ) ;
180+ process . exit ( 1 ) ;
181+ }
182+
183+ await clone ( slug , {
184+ language : values . language ,
185+ force : values . force ,
156186 } ) ;
157187 break ;
158188 }
@@ -166,17 +196,12 @@ async function main() {
166196
167197 await info ( slug , {
168198 language : values . language ,
199+ json : values . json ,
169200 } ) ;
170201 break ;
171202 }
172203
173204 case "edit" : {
174- if ( ! slug ) {
175- console . error ( "Usage: temper edit <slug> [-l language]" ) ;
176- console . error ( "Example: temper edit sort-array -l ruby" ) ;
177- process . exit ( 1 ) ;
178- }
179-
180205 await edit ( slug , {
181206 language : values . language ,
182207 editor : values . editor ,
@@ -195,6 +220,34 @@ async function main() {
195220 break ;
196221 }
197222
223+ case "add" : {
224+ if ( ! slug ) {
225+ console . error ( "Usage: temper add <slug> [-l language]" ) ;
226+ console . error ( "Example: temper add my-helper" ) ;
227+ process . exit ( 1 ) ;
228+ }
229+
230+ await add ( slug , {
231+ language : values . language ,
232+ editor : values . editor ,
233+ } ) ;
234+ break ;
235+ }
236+
237+ case "remove" : {
238+ if ( ! slug ) {
239+ console . error ( "Usage: temper remove <slug> [-l language]" ) ;
240+ console . error ( "Example: temper remove my-helper" ) ;
241+ process . exit ( 1 ) ;
242+ }
243+
244+ await remove ( slug , {
245+ language : values . language ,
246+ force : values . force ,
247+ } ) ;
248+ break ;
249+ }
250+
198251 case "cache" : {
199252 const cache = new SnippetCache ( ) ;
200253 const subcommand = rest [ 0 ] ;
@@ -216,6 +269,16 @@ async function main() {
216269 break ;
217270 }
218271
272+ case "config" : {
273+ await showConfig ( { json : values . json } ) ;
274+ break ;
275+ }
276+
277+ case "mcp" : {
278+ await mcp ( ) ;
279+ break ;
280+ }
281+
219282 default :
220283 console . error ( `Unknown command: ${ command } ` ) ;
221284 console . log ( HELP ) ;
0 commit comments