summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/README.md32
-rw-r--r--examples/catj.ts (renamed from examples/catjson.ts)10
2 files changed, 30 insertions, 12 deletions
diff --git a/examples/README.md b/examples/README.md
index c4def7b7c..6a4924f5d 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,18 +1,36 @@
-# Deno Example Programs
+# Deno example programs
-These files are accessible for import via "https://deno.land/std/examples/".
+This module contains small scripts that demonstrate use of Deno and its standard library.
-Try it:
+You can run these examples by importing them via `deno` command:
```
-> deno https://deno.land/std/examples/gist.ts README.md
+> deno https://deno.land/std/examples/echo_server.ts --allow-net
```
-## Alias Based Installation
+Some of them are useful CLI programs that can be installed as executables:
-Add this to your `.bash_profile`
+`cat.ts` - print file to standard output
```
+deno install deno_cat https://deno.land/examples.cat.ts --allow-read
+deno_cat file.txt
+```
+
+`catj.ts` - print flattened JSON to standard output
+
+```
+deno install catj https://deno.land/examples/catj.ts --allow-read
+catj example.json
+catj file1.json file2.json
+echo example.json | catj -
+```
+
+`gist.ts` - easily create and upload Gists
+
+```
+deno install gist https://deno.land/examples/gist.ts --allow-net --allow-env
export GIST_TOKEN=ABC # Generate at https://github.com/settings/tokens
-alias gist="deno --allow-net --allow-env https://deno.land/std/examples/gist.ts"
+gist --title "Example gist 1" script.ts
+gist --t "Example gist 2" script2.ts
```
diff --git a/examples/catjson.ts b/examples/catj.ts
index 010a3506a..82fec5ff9 100644
--- a/examples/catjson.ts
+++ b/examples/catj.ts
@@ -4,7 +4,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
// Install using `deno install`
-// $ deno install catjson https://deno.land/std/examples/catjson.ts --allow-read
+// $ deno install catj https://deno.land/std/examples/catj.ts --allow-read
/* eslint-disable @typescript-eslint/no-use-before-define */
import { parse } from "../flags/mod.ts";
@@ -83,15 +83,15 @@ async function main(): Promise<void> {
const parsedArgs = parse(Deno.args.slice(1));
if (parsedArgs.h || parsedArgs.help || parsedArgs._.length === 0) {
- console.log("Usage: catjson [-h|--help] [file...]");
+ console.log("Usage: catj [-h|--help] [file...]");
console.log();
console.log("Examples:");
console.log();
- console.log("// print file:\n catjson file.json");
+ console.log("// print file:\n catj file.json");
console.log();
- console.log("// print multiple files:\n catjson file1.json file2.json");
+ console.log("// print multiple files:\n catj file1.json file2.json");
console.log();
- console.log("// print from stdin:\n cat file.json | catjson -");
+ console.log("// print from stdin:\n cat file.json | catj -");
}
if (parsedArgs._[0] === "-") {