Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename catjson.ts to catj.ts #533

Merged
merged 6 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -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
```
10 changes: 5 additions & 5 deletions examples/catjson.ts → examples/catj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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] === "-") {
Expand Down