Created
March 14, 2025 00:34
-
-
Save JosXa/b614d14deaef4a087c3188544ea198f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "@johnlindquist/kit" | |
import type { Choice } from "@johnlindquist/kit" | |
import gis from "g-i-s" | |
const query = await arg("Enter image search term") | |
const images = await new Promise<any[]>((resolve, reject) => { | |
gis(query, (error, results) => { | |
if (error) { | |
reject(error) | |
} else { | |
resolve(results) | |
} | |
}) | |
}) | |
const choices = images.map((image) => ({ | |
name: image.url, | |
value: image.url, | |
preview: `<img class="w-full" src="${image.url}" />`, | |
onSubmit: async () => { | |
await copy(image.url); | |
} | |
} satisfies Choice)) | |
const imageUrl = await arg("Pick an image", choices) | |
console.log(`Selected image URL: ${imageUrl}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment