File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,7 @@ script.
223
223
- ** flags:** Deno's ` std/flags ` module.
224
224
225
225
``` ts
226
- console . log ($ .blue . bold ( " Hello world! " ) );
226
+ const args : flags . Args = flags . parse ($ .args );
227
227
```
228
228
229
229
## Variables
@@ -240,6 +240,8 @@ script.
240
240
` "piped" ` , ` "null" ` or ` number ` . Will be reverted to default after all async
241
241
ops are done. Default: ` "piped" `
242
242
- ** $.throwErrors:** Throw errors instead of calling ` Deno.exit ` .
243
+ - ** $.args:** Equivalent to ` Deno.args ` , but without the script name as first
244
+ argument.
243
245
- ** $.startTime:** The execution start time in ms.
244
246
- ** $.time:** The time left since execution start (now() - $.startTime).
245
247
- ** $.quote:** Parser method that is used to safely quote strings. Used by:
Original file line number Diff line number Diff line change @@ -61,8 +61,9 @@ export function dzx() {
61
61
async (
62
62
{ worker, ...perms } ,
63
63
script ?: string ,
64
- _args ? : Array < string > ,
64
+ args : Array < string > = [ ] ,
65
65
) => {
66
+ $ . args = args ;
66
67
if ( script ) {
67
68
$ . mainModule = addProtocool ( script ) ;
68
69
if ( worker ) {
@@ -90,6 +91,9 @@ export function dzx() {
90
91
import "${ new URL ( "./src/runtime/mod.ts" , Deno . mainModule ) } ";
91
92
$.mainModule = "${ $ . mainModule } ";
92
93
$.startTime = ${ $ . startTime } ;
94
+ $.args = JSON.parse(decodeURIComponent("${
95
+ encodeURIComponent ( JSON . stringify ( $ . args ) )
96
+ } "));
93
97
await import("${ $ . mainModule } ");
94
98
if ($.verbose) {
95
99
const end = Date.now();
Original file line number Diff line number Diff line change @@ -9,10 +9,11 @@ export type $ = typeof exec & typeof colors & {
9
9
verbose : boolean ;
10
10
stdout : NonNullable < Deno . RunOptions [ "stdout" ] > ;
11
11
stderr : NonNullable < Deno . RunOptions [ "stderr" ] > ;
12
+ args : Array < string > ;
13
+ quote : typeof shq ;
12
14
throwErrors : boolean ;
13
15
startTime : number ;
14
16
time : number ;
15
- quote : typeof shq ;
16
17
} ;
17
18
18
19
export const $ : $ = exec as $ ;
@@ -25,6 +26,7 @@ $.mainModule = "";
25
26
$ . verbose = false ;
26
27
$ . stdout = "piped" ;
27
28
$ . stderr = "piped" ;
29
+ $ . args = [ ] ;
28
30
$ . quote = shq ;
29
31
$ . throwErrors = false ;
30
32
$ . startTime = Date . now ( ) ;
You can’t perform that action at this time.
0 commit comments