2019-07-11 05:58:18 -04:00
|
|
|
# Deno example programs
|
2018-12-19 13:50:48 -05:00
|
|
|
|
2019-08-05 18:00:28 -04:00
|
|
|
This module contains small scripts that demonstrate use of Deno and its standard
|
|
|
|
module.
|
2018-12-19 13:50:48 -05:00
|
|
|
|
2019-08-05 18:00:28 -04:00
|
|
|
You can run these examples using just their URL or install the example as an
|
|
|
|
executable script which references the URL. (Think of installing as creating a
|
|
|
|
bookmark to a program.)
|
2018-12-24 10:28:01 -05:00
|
|
|
|
2019-08-05 18:00:28 -04:00
|
|
|
### A TCP echo server
|
2018-12-19 13:50:48 -05:00
|
|
|
|
2019-08-05 18:00:28 -04:00
|
|
|
```shell
|
|
|
|
deno https://deno.land/std/examples/echo_server.ts --allow-net
|
|
|
|
```
|
2018-12-19 13:50:48 -05:00
|
|
|
|
2019-08-05 18:00:28 -04:00
|
|
|
Or
|
2018-12-24 10:28:01 -05:00
|
|
|
|
2019-08-05 18:00:28 -04:00
|
|
|
```shell
|
|
|
|
deno install echo_server https://deno.land/std/examples/echo_server.ts --allow-net
|
2018-12-19 13:50:48 -05:00
|
|
|
```
|
2019-08-05 18:00:28 -04:00
|
|
|
|
|
|
|
### cat - print file to standard output
|
|
|
|
|
|
|
|
```shell
|
2019-08-17 00:43:34 -04:00
|
|
|
deno install deno_cat https://deno.land/std/examples/cat.ts --allow-read
|
2019-07-11 05:58:18 -04:00
|
|
|
deno_cat file.txt
|
|
|
|
```
|
|
|
|
|
2019-08-05 18:00:28 -04:00
|
|
|
### catj - print flattened JSON to standard output
|
2019-07-11 05:58:18 -04:00
|
|
|
|
2019-08-05 18:00:28 -04:00
|
|
|
A very useful command by Soheil Rashidi ported to Deno.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
deno install catj https://deno.land/std/examples/catj.ts --allow-read
|
2019-07-11 05:58:18 -04:00
|
|
|
catj example.json
|
|
|
|
catj file1.json file2.json
|
|
|
|
echo example.json | catj -
|
|
|
|
```
|
|
|
|
|
2019-10-21 10:36:01 -04:00
|
|
|
### curl - print the contents of a url to standard output
|
|
|
|
|
|
|
|
```shell
|
2020-01-15 09:05:22 -05:00
|
|
|
deno --allow-net=deno.land https://deno.land/std/examples/curl.ts -- https://deno.land/
|
2019-10-21 10:36:01 -04:00
|
|
|
```
|
|
|
|
|
2019-08-05 18:00:28 -04:00
|
|
|
### gist - easily create and upload Gists
|
2019-07-11 05:58:18 -04:00
|
|
|
|
|
|
|
```
|
2018-12-19 13:50:48 -05:00
|
|
|
export GIST_TOKEN=ABC # Generate at https://github.com/settings/tokens
|
2019-08-05 18:00:28 -04:00
|
|
|
deno install gist https://deno.land/std/examples/gist.ts --allow-net --allow-env
|
2019-07-11 05:58:18 -04:00
|
|
|
gist --title "Example gist 1" script.ts
|
|
|
|
gist --t "Example gist 2" script2.ts
|
2018-12-19 13:50:48 -05:00
|
|
|
```
|