Created
May 22, 2024 09:05
-
-
Save tanishqmanuja/19b328058343eb48ac28e7e6110b0f0f to your computer and use it in GitHub Desktop.
Bun Github Repos Cli
This file contains 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 { $ } from "bun"; | |
import { parseArgs } from "util"; | |
const { values, positionals } = parseArgs({ | |
args: Bun.argv, | |
options: { | |
user: { | |
short: "u", | |
type: "string", | |
}, | |
}, | |
strict: true, | |
allowPositionals: true, | |
}); | |
const user = values.user ?? ""; | |
const query = positionals[2] ?? ""; | |
let cmnd = `gh repo list ${user} -L 100 | fzf`; | |
if (query) { | |
cmnd += ` --query ${query}`; | |
} | |
const repo = await $`${{ raw: cmnd }}`.text().then((text) => { | |
return text?.split("\t")[0]; | |
}); | |
if (!repo) { | |
console.warn("No repo selected"); | |
process.exit(1); | |
} | |
await $`gh repo view --web ${repo}`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment