/// <reference lib="dom" />
// Open a URL (or the current project) in the NOSEbrowser.

import { openBrowser } from "@/js/browser"
import { setStatus, latestId } from "@/js/scrollback"
import { currentAppUrl } from "@/js/webapp"

export default function (url?: string) {
    const currentUrl = url ?? currentAppUrl()
    if (currentUrl) {
        openBrowser(currentUrl, "command")
    } else {
        setTimeout(() => setStatus(latestId()!, "error"), 0)
        return "usage: browse <url>"
    }
}