pterm 0.0.17 → 0.0.18

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.
Files changed (4) hide show
  1. package/README.md +22 -0
  2. package/index.js +2 -0
  3. package/package.json +1 -1
  4. package/util.js +27 -0
package/README.md CHANGED
@@ -163,6 +163,28 @@ pterm search --q="text generation"
163
163
  pterm search "tts speech synthesis" --mode=balanced --min-match=2 --limit=8
164
164
  ```
165
165
 
166
+ ## which
167
+
168
+ Resolve the executable path for a command name through Pinokio's environment.
169
+
170
+ ### syntax
171
+
172
+ ```
173
+ pterm which <command> [--json]
174
+ ```
175
+
176
+ - `--json`: (optional) print the raw JSON response instead of only the path.
177
+
178
+ ### examples
179
+
180
+ ```
181
+ pterm which node
182
+ ```
183
+
184
+ ```
185
+ pterm which git --json
186
+ ```
187
+
166
188
  ## status
167
189
 
168
190
  Get app status by app id.
package/index.js CHANGED
@@ -62,6 +62,8 @@ const isHttpUri = (value) => typeof value === "string" && /^https?:\/\//i.test(v
62
62
  await util.setStar(argv, true)
63
63
  } else if (cmd === "unstar") {
64
64
  await util.setStar(argv, false)
65
+ } else if (cmd === "which") {
66
+ await util.which(argv)
65
67
  } else if (cmd === "status") {
66
68
  await util.status(argv)
67
69
  } else if (cmd === "logs") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pterm",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/util.js CHANGED
@@ -130,6 +130,33 @@ class Util {
130
130
  })
131
131
  this.printJson(response.data)
132
132
  }
133
+ async which(argv) {
134
+ if (argv._.length <= 1) {
135
+ console.error("required argument: <command>")
136
+ return
137
+ }
138
+ const command = String(argv._[1]).trim()
139
+ if (!command) {
140
+ console.error("required argument: <command>")
141
+ return
142
+ }
143
+ try {
144
+ const response = await axios.get(`http://localhost:42000/pinokio/path/${encodeURIComponent(command)}`)
145
+ if (argv.json) {
146
+ this.printJson(response.data)
147
+ } else if (response.data && response.data.path) {
148
+ process.stdout.write(String(response.data.path))
149
+ process.stdout.write("\n")
150
+ }
151
+ } catch (error) {
152
+ if (error && error.response && error.response.status === 404) {
153
+ console.error(`command not found: ${command}`)
154
+ process.exitCode = 1
155
+ return
156
+ }
157
+ throw error
158
+ }
159
+ }
133
160
  async filepicker(argv) {
134
161
  const rpc = new RPC("ws://localhost:42000")
135
162
  if (argv.path) {