Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ This permanently disables telemetry. Your preference is stored locally at `~/.co

## Credits

Built with [OpenTUI](https://github.com/anthropics/opentui)
Built with [OpenTUI](https://github.com/anomalyco/opentui)
17 changes: 14 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
#!/usr/bin/env bun
import { createCliRenderer } from "@opentui/core";
import { exec } from "child_process";
import { platform } from "os";
import { HackerNewsApp } from "./app";
import { checkForUpdates, currentVersion } from "./version";
import { setTelemetryEnabled } from "./config";
import * as telemetry from "./telemetry";
import { open } from "fs";

const COLORS = {
bg: "#1a1a1a",
};

function openUrl(url: string): void {
const os = platform();
if (os === "darwin") {
exec(`open "${url}"`);
} else if (os === "win32") {
exec(`start "" "${url}"`);
} else {
exec(`xdg-open "${url}"`);
}
}

function parseArgs(): { storyId?: number } {
const args = process.argv.slice(2);
let storyId: number | undefined;
Expand Down Expand Up @@ -64,9 +77,7 @@ async function main() {
});

const app = new HackerNewsApp(renderer, {
onOpenUrl: (url) => {
exec(`open "${url}"`);
},
onOpenUrl: openUrl,
onExit: async () => {
await telemetry.flushSync();
renderer.destroy();
Expand Down