Skip to content

Commit

Permalink
Fixes pkgxdev#214
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Dec 6, 2022
1 parent 30f7be5 commit 405c7af
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import help from "./app.help.ts"
import { print } from "utils"
import X from "./app.X.ts"
import Path from "path"
import { Verbosity } from "./types.ts"

const [args, {sync}] = useArgs(Deno.args, Deno.execPath())
const [args, {sync, verbosity}] = useArgs(Deno.args, Deno.execPath())
const version = `${(await useRequirementsFile(new URL(import.meta.url).path().join("../../README.md")).swallow(/not-found/))?.version}+dev`
// ^^ this is statically replaced at deployment

Expand All @@ -30,10 +31,10 @@ try {
}

if (args.mode == "exec" || args.mode == undefined) {
announce()
await announce()
await exec(args)
} else if (args.mode == "eXec") {
announce()
await announce()
await X(args)
} else switch (args.mode[1]) {
case "env":
Expand All @@ -43,7 +44,7 @@ try {
await help()
break
case "version":
await print(`tea ${version}`)
await print_version()
break
case "prefix":
await print(usePrefix().string)
Expand All @@ -52,13 +53,23 @@ try {
await err_handler(err)
}

function announce() {
async function announce() {
const self = new Path(Deno.execPath())
const prefix = usePrefix().string

if (self.basename() == "deno") {
console.verbose({ deno: self.string, prefix, import: import.meta, tea: version })
} else {
console.verbose(`${prefix}/tea.xyz/v${version}/bin/tea`)
switch (verbosity) {
case Verbosity.debug:
if (self.basename() == "deno") {
console.debug({ deno: self.string, prefix, import: import.meta, tea: version })
} else {
console.debug(`${prefix}/tea.xyz/v${version}/bin/tea`)
}
break
case Verbosity.loud:
await print_version()
}
}

async function print_version() {
await print(`tea ${version}`)
}

0 comments on commit 405c7af

Please sign in to comment.