Skip to content

Commit 7808143

Browse files
committed
docs: update readme
1 parent cb1418a commit 7808143

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

README.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,41 @@ await $`mkdir /tmp/${name}`; // <-- string will be safly quoted to: /tmp/'foo ba
5454
deno install --allow-all -r -f https://deno.land/x/dzx/dzx.ts
5555
```
5656

57-
## Documentation
57+
## Usage
5858

5959
To start writing a dzx script, add next shebang at the beginning of your script:
6060

6161
```
6262
#!/usr/bin/env dzx
6363
```
6464

65+
### Javascript
66+
6567
Now you will be able to run your script as:
6668

6769
```shell
6870
chmod +x ./script.js
6971
./script.js
7072
```
7173

72-
If you want to use typescript you need to add a tripple slash reference for the
73-
typings at the top of the file, but not before the shebang line.
74+
### Typescript
75+
76+
If you want to use typescript you need to add a tripple slash reference to get
77+
global typings working.
7478

7579
```
7680
#!/usr/bin/env dzx
7781
/// <reference path="https://deno.land/x/dzx/types.d.ts" />
7882
```
7983

84+
Or you can import all symbol directly from `dzx/mod.ts` instead of using
85+
globals.
86+
87+
```ts
88+
#!/usr/bin/env dzx
89+
import { $, cd, parseFlags } from "https://deno.land/x/dzx/mod.ts";
90+
```
91+
8092
Now you will be able to run your typescript script the same way as your js
8193
script:
8294

@@ -85,14 +97,20 @@ chmod +x ./script.ts
8597
./script.ts
8698
```
8799

88-
You can also import all symbol directly from `dzx/mod.ts` instead of using
89-
globals.
100+
## Remote usage
90101

91-
```ts
92-
#!/usr/bin/env dzx
93-
import { $ } from "https://deno.land/x/dzx/mod.ts";
102+
You can also use `dzx` directly without installation by using the following
103+
shebang. This also allows you to explicitly set the permissions.
104+
105+
```typescript
106+
#!/usr/bin/env deno run --allow-run --allow-read --allow-env https://deno.land/x/dzx/dzx.ts
107+
/// <reference path="https://deno.land/x/dzx/types.d.ts" />
108+
109+
console.log(`Hello ${$.blue.bold("world")}!`);
94110
```
95111

112+
## API
113+
96114
### `$.verbose`
97115

98116
Enable debugging output.
@@ -182,15 +200,6 @@ Deno's `std/flags` module for parsing command-line arguments.
182200
The quote methods quotes safly a string. by default the `shq` package is used.
183201
Can be overidden with `$.quote`.
184202

185-
## Remote usage
186-
187-
```typescript
188-
#!/usr/bin/env deno run --allow-run --allow-read --allow-env https://deno.land/x/dzx/dzx.ts
189-
/// <reference path="https://deno.land/x/dzx/types.d.ts" />
190-
191-
console.log(`Hello ${$.blue.bold("world")}!`);
192-
```
193-
194203
## Contributing
195204

196205
Any kind of contribution is welcome!

0 commit comments

Comments
 (0)