Skip to content

Commit

Permalink
Formalize numpty mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Sep 16, 2022
1 parent 2f2e0b0 commit 5c74abb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/hooks/useCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ async function grab({ readURL: url, writeFilename: dst, privateRepo = false }: {
case 304:
console.verbose("304: not modified")
return // not modified
case 404:
throw new Error(`404: ${url}`)
default:
throw new Error()
if (useFlags().numpty && writeFilename.isFile()) {
return
} else {
throw new Error(`${rsp.status}: ${url}`)
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Flags {
verbosity: Verbosity
magic: boolean
json: boolean
numpty: boolean
}

interface ConvenienceFlags {
Expand All @@ -32,7 +33,8 @@ export default function useFlags(): Flags & ConvenienceFlags {
flags = {
verbosity: getVerbosity({}),
magic: getMagic(undefined),
json: Deno.env.get("JSON") == '1' //FIXME use the lib
json: !!Deno.env.get("JSON"),
numpty: !!Deno.env.get("NUMPTY")
}
applyVerbosity()
}
Expand Down Expand Up @@ -130,7 +132,8 @@ export function useArgs(args: string[]): ReturnValue {
flags = {
verbosity: getVerbosity({ v, verbose, silent}),
magic: getMagic(muggle),
json
json: json ?? !!Deno.env.get("JSON"),
numpty: !!Deno.env.get("NUMPTY")
}

applyVerbosity()
Expand Down

0 comments on commit 5c74abb

Please sign in to comment.