Skip to content

Instantly share code, notes, and snippets.

@tanishqmanuja
Created May 22, 2024 09:05
Show Gist options
  • Save tanishqmanuja/19b328058343eb48ac28e7e6110b0f0f to your computer and use it in GitHub Desktop.
Save tanishqmanuja/19b328058343eb48ac28e7e6110b0f0f to your computer and use it in GitHub Desktop.
Bun Github Repos Cli
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