Skip to content

Commit 41b736c

Browse files
traynhamPitNikola
authored andcommitted
Example javascript (node) template.
1 parent e6c783c commit 41b736c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

templates/script-command.template.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env node
2+
3+
// Raycast Script Command Template
4+
//
5+
// Dependency: This script requires Nodejs.
6+
// Install Node: https://nodejs.org/en/download/
7+
//
8+
// Duplicate this file and remove ".template." from the filename to get started.
9+
// See full documentation here: https://github.com/raycast/script-commands
10+
//
11+
// Required parameters:
12+
// @raycast.schemaVersion 1
13+
// @raycast.title My First Script
14+
// @raycast.mode fullOutput
15+
// @raycast.packageName Raycast Scripts
16+
//
17+
// Optional parameters:
18+
// @raycast.icon 🤖
19+
// @raycast.argument1 { "type": "text", "placeholder": "js, css, html", "optional": true}
20+
// @raycast.argument2 { "type": "text", "placeholder": "query" }
21+
//
22+
// Documentation:
23+
// @raycast.description Write a nice and descriptive summary about your script command here
24+
// @raycast.author Your name
25+
// @raycast.authorURL An URL for one of your social medias
26+
27+
const { exec } = require('child_process')
28+
29+
// Use destructuring to grab arguments.
30+
// Use slice to start from position 3.
31+
let [topic, query] = process.argv.slice(2)
32+
let uri = `https://developer.mozilla.org/search?topic=${topic}&q=${encodeURIComponent(query)}`
33+
34+
// console.log() displays output in fullOutput mode.
35+
console.log(`The arguments are: \n ${process.argv.join('\n ')}\n`)
36+
console.log(`Your topic is "${topic}"`)
37+
console.log(`Your query is "${query}"`)
38+
console.log(`Your query uri encoded is "${encodeURIComponent(query)}"`)
39+
console.log(`The uri is "${uri}"`)
40+
41+
// Uncomment the exec line below to open this query in your web browser.
42+
// Use double quotes around the uri to avoid processing issues.
43+
//exec(`open "${uri}"`)

0 commit comments

Comments
 (0)