@@ -11,7 +11,7 @@ import manifest from "./deno.json" with { type: "json" };
11
11
12
12
export * from "./mod.ts" ;
13
13
14
- const args = parseArgs ( Deno . args , {
14
+ const parseOptions = {
15
15
string : [
16
16
"output" ,
17
17
"config" ,
@@ -28,13 +28,15 @@ const args = parseArgs(Deno.args, {
28
28
alias : { "output" : "o" , "help" : "h" , "version" : "V" } ,
29
29
default : {
30
30
"output" : "./typefetch.d.ts" ,
31
- "import" : "https://raw.githubusercontent.com/denosaurs/typefetch/main" ,
31
+ "import" : "__npm" in globalThis
32
+ ? manifest . name
33
+ : "https://raw.githubusercontent.com/denosaurs/typefetch/main" ,
32
34
"include-server-urls" : true ,
33
35
"include-absolute-url" : false ,
34
36
"include-relative-url" : false ,
35
37
"experimental-urlsearchparams" : false ,
36
38
} ,
37
- unknown : ( arg , key ) => {
39
+ unknown : ( arg : string , key ?: string ) => {
38
40
if ( key === undefined ) return ;
39
41
40
42
console . error (
@@ -43,7 +45,9 @@ const args = parseArgs(Deno.args, {
43
45
) ;
44
46
Deno . exit ( 1 ) ;
45
47
} ,
46
- } ) ;
48
+ } as const ;
49
+
50
+ const args = parseArgs ( Deno . args , parseOptions ) ;
47
51
48
52
if ( args . help ) {
49
53
// deno-fmt-ignore
@@ -52,14 +56,14 @@ if (args.help) {
52
56
`Options:\n` +
53
57
` -h, --help Print this help message\n` +
54
58
` -V, --version Print the version of TypeFetch\n` +
55
- ` -o, --output <PATH> Output file path (default: typefetch.d.ts )\n` +
59
+ ` -o, --output <PATH> Output file path (default: ${ parseOptions . default [ "output" ] } )\n` +
56
60
` --config <PATH> File path to the tsconfig.json file\n` +
57
- ` --import <PATH> Import path for TypeFetch (default: https://raw.githubusercontent.com/denosaurs/typefetch/main )\n` +
61
+ ` --import <PATH> Import path for TypeFetch (default: ${ parseOptions . default [ "import" ] } )\n` +
58
62
` --base-urls <URLS> A comma separated list of custom base urls for paths to start with\n` +
59
- ` --include-server-urls Include server URLs from the schema in the generated paths (default: true )\n` +
60
- ` --include-absolute-url Include absolute URLs in the generated paths (default: false )\n` +
61
- ` --include-relative-url Include relative URLs in the generated paths (default: false )\n` +
62
- ` --experimental-urlsearchparams Enable the experimental fully typed URLSearchParams type (default: false )\n` ,
63
+ ` --include-server-urls Include server URLs from the schema in the generated paths (default: ${ parseOptions . default [ "include-server-urls" ] } )\n` +
64
+ ` --include-absolute-url Include absolute URLs in the generated paths (default: ${ parseOptions . default [ "include-absolute-url" ] } )\n` +
65
+ ` --include-relative-url Include relative URLs in the generated paths (default: ${ parseOptions . default [ "include-relative-url" ] } )\n` +
66
+ ` --experimental-urlsearchparams Enable the experimental fully typed URLSearchParams type (default: ${ parseOptions . default [ "experimental-urlsearchparams" ] } )\n` ,
63
67
) ;
64
68
Deno . exit ( 0 ) ;
65
69
}
0 commit comments