Skip to content

Commit

Permalink
docs: fmt reamde's and add discord budget (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed Feb 2, 2021
1 parent f5c9be5 commit 821f13d
Show file tree
Hide file tree
Showing 10 changed files with 1,523 additions and 935 deletions.
1,141 changes: 730 additions & 411 deletions CHANGELOG.md

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Contributing to Cliffy

First off, thank you for considering contributing to cliffy. Here are a few things you may find helpful.
First off, thank you for considering contributing to cliffy. Here are a few
things you may find helpful.

### Get in touch

- ❓ Ask general support questions on [StackOverflow](https://stackoverflow.com/questions/tagged/cliffy) (using the `cliffy` tag) or in the [chat](https://discord.gg/nktwtG).
- 👨‍💻 Use [issues](https://github.com/c4spar/deno-cliffy/issues/new) to report bugs, request new features and discuss your contributions.
- ❓ Ask general support questions on
[StackOverflow](https://stackoverflow.com/questions/tagged/cliffy) (using the
`cliffy` tag) or in the [chat](https://discord.gg/nktwtG).
- 👨‍💻 Use [issues](https://github.com/c4spar/deno-cliffy/issues/new) to report
bugs, request new features and discuss your contributions.
- 💬 Discuss topics in the [chat](https://discord.gg/V8XpuHdzz2).

### Contributing to development

Before you submit your PR please consider the following guidelines:

- 🕶 Follow Deno's [style guide](https://deno.land/manual/contributing/style_guide#typescript).
- 🕶 Follow Deno's
[style guide](https://deno.land/manual/contributing/style_guide#typescript).
- ✨ Make sure to run `deno fmt` before committing.
- 📄 [Conventional Commits](https://conventionalcommits.org) are appreciated.
- ⚙️ Test your changes locally with `deno test -r --allow-env --unstable`.
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<a href="https://deno.land/">
<img alt="Deno version" src="https://img.shields.io/badge/deno-^1.2.0-blue?logo=deno" />
</a>
<a href="https://discord.gg/nktwtG">
<img alt="Discord" src="https://img.shields.io/badge/join-chat-blue?logo=discord&logoColor=white" />
</a>
<a href="https://github.com/c4spar/deno-cliffy/actions?query=workflow%3Aci">
<img alt="Licence" src="https://img.shields.io/github/license/c4spar/deno-cliffy?logo=github" />
</a>
Expand All @@ -26,25 +29,33 @@
<sub>>_ A collection of modules for creating interactive command line tools.</sub>
</p>

> This project is still under development. Expect breaking changes. If you find a bug or have a feature request feel free to create an issue.
> This project is still under development. Expect breaking changes. If you find
> a bug or have a feature request feel free to create an issue.
## ❯ Modules

* **[ansi](ansi/):** Chainable ansi escape sequences to show, hide and move cli cursor, erase output and scroll window.
- **[ansi](ansi/):** Chainable ansi escape sequences to show, hide and move cli
cursor, erase output and scroll window.

* **[command](command/):** Create flexible command line interfaces with type checking, auto generated help and out of the box support for shell completions (inspired by [node.js's](http://nodejs.org) [commander.js](https://github.com/tj/commander.js/blob/master/Readme.md)).
- **[command](command/):** Create flexible command line interfaces with type
checking, auto generated help and out of the box support for shell completions
(inspired by [node.js's](http://nodejs.org)
[commander.js](https://github.com/tj/commander.js/blob/master/Readme.md)).

* **[flags](flags/):** Parse command line arguments.
- **[flags](flags/):** Parse command line arguments.

* **[keycode](keycode/):** Parse ANSI key codes.
- **[keycode](keycode/):** Parse ANSI key codes.

* **[prompt](prompt/):** Create interactive prompts like: checkbox, confirm, input, number, select, etc...
- **[prompt](prompt/):** Create interactive prompts like: checkbox, confirm,
input, number, select, etc...

* **[table](table/):** Create cli table's with border, padding, nested table's, etc...
- **[table](table/):** Create cli table's with border, padding, nested table's,
etc...

## ❯ Contributing

Any kind of contribution is welcome! Please take a look at the [contributing guidelines](CONTRIBUTING.md).
Any kind of contribution is welcome! Please take a look at the
[contributing guidelines](CONTRIBUTING.md).

## ❯ License

Expand Down
94 changes: 62 additions & 32 deletions ansi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<a href="https://doc.deno.land/https/deno.land/x/cliffy/ansi/mod.ts">
<img alt="doc" src="https://img.shields.io/badge/deno-doc-yellow?logo=deno" />
</a>
<a href="https://discord.gg/nktwtG">
<img alt="Discord" src="https://img.shields.io/badge/join-chat-blue?logo=discord&logoColor=white" />
</a>
<a href="https://github.com/c4spar/deno-cliffy/blob/master/LICENSE">
<img alt="Licence" src="https://img.shields.io/github/license/c4spar/deno-cliffy?logo=github" />
</a>
Expand Down Expand Up @@ -45,48 +48,66 @@

## ❯ Install

This module can be imported directly from the repo and from following registries.
This module can be imported directly from the repo and from following
registries.

Deno Registry

```typescript
import { ansi, colors, tty, cursorTo } from "https://deno.land/x/cliffy@<version>/ansi/mod.ts";
import {
ansi,
colors,
cursorTo,
tty,
} from "https://deno.land/x/cliffy@<version>/ansi/mod.ts";
```

Nest Registry

```typescript
import { ansi, colors, tty, cursorTo } from "https://x.nest.land/cliffy@<version>/ansi/mod.ts";
import {
ansi,
colors,
cursorTo,
tty,
} from "https://x.nest.land/cliffy@<version>/ansi/mod.ts";
```

Github

```typescript
import { ansi, colors, tty, cursorTo } from "https://raw.githubusercontent.com/c4spar/deno-cliffy/<version>/ansi/mod.ts";
import {
ansi,
colors,
cursorTo,
tty,
} from "https://raw.githubusercontent.com/c4spar/deno-cliffy/<version>/ansi/mod.ts";
```

## ❯ Usage

### Ansi

The ansi module exports an `ansi` object with chainable methods and properties for generating ansi escape sequence
strings. The last property must be invoked as a method to generate the ansi string.
The ansi module exports an `ansi` object with chainable methods and properties
for generating ansi escape sequence strings. The last property must be invoked
as a method to generate the ansi string.

```typescript
import { ansi } from "https://deno.land/x/cliffy/ansi/ansi.ts";

console.log(
ansi.cursorUp.cursorLeft.eraseDown()
ansi.cursorUp.cursorLeft.eraseDown(),
);
```

If a method takes some arguments, you have to invoke the `.toString()` method to generate the ansi string.
If a method takes some arguments, you have to invoke the `.toString()` method to
generate the ansi string.

```typescript
import { ansi } from "https://deno.land/x/cliffy/ansi/ansi.ts";

console.log(
ansi.cursorUp(2).cursorLeft.eraseDown(2).toString()
ansi.cursorUp(2).cursorLeft.eraseDown(2).toString(),
);
```

Expand All @@ -96,28 +117,34 @@ Convert to `Uint8Array`:
import { ansi } from "https://deno.land/x/cliffy/ansi/ansi.ts";

await Deno.stdout.write(
ansi.cursorUp.cursorLeft.eraseDown.toBuffer()
ansi.cursorUp.cursorLeft.eraseDown.toBuffer(),
);
```

You can also directly import the ansi escape methods from the `ansi_escapes.ts` module.
You can also directly import the ansi escape methods from the `ansi_escapes.ts`
module.

```typescript
import { cursorTo, eraseDown, image, link } from "https://deno.land/x/cliffy/ansi/ansi_escapes.ts";
import {
cursorTo,
eraseDown,
image,
link,
} from "https://deno.land/x/cliffy/ansi/ansi_escapes.ts";

const response = await fetch("https://deno.land/images/hashrock_simple.png");
const imageBuffer: ArrayBuffer = await response.arrayBuffer();

console.log(
cursorTo(0, 0) +
eraseDown() +
image(imageBuffer, {
width: 29,
preserveAspectRatio: true,
}) +
"\n " +
link("Deno Land", "https://deno.land") +
"\n",
eraseDown() +
image(imageBuffer, {
width: 29,
preserveAspectRatio: true,
}) +
"\n " +
link("Deno Land", "https://deno.land") +
"\n",
);
```

Expand All @@ -127,16 +154,17 @@ $ deno run https://deno.land/x/cliffy/examples/ansi/functional.ts

### Tty

The tty module exports a `tty` object which works almost the same way as the `ansi` module. The only difference is, the
`tty` module writes the ansi escape sequences directly to stdout.
The tty module exports a `tty` object which works almost the same way as the
`ansi` module. The only difference is, the `tty` module writes the ansi escape
sequences directly to stdout.

```typescript
import { tty } from "https://deno.land/x/cliffy/ansi/tty.ts";

tty.cursorSave
.cursorHide
.cursorTo(0, 0)
.eraseScreen();
.cursorHide
.cursorTo(0, 0)
.eraseScreen();
```

Create a new instance.
Expand All @@ -146,19 +174,20 @@ import { tty } from "https://deno.land/x/cliffy/ansi/tty.ts";

const myTty = tty({
stdout: Deno.stdout,
stdin: Deno.stdin
stdin: Deno.stdin,
});

myTty.cursorSave
.cursorHide
.cursorTo(0, 0)
.eraseScreen();
.cursorHide
.cursorTo(0, 0)
.eraseScreen();
```

### Colors

The colors module is a simple and tiny chainable wrapper around [deno's std colors](https://deno.land/std/fmt/colors.ts)
module and works similar to node's [chalk](https://github.com/chalk/chalk) module.
The colors module is a simple and tiny chainable wrapper around
[deno's std colors](https://deno.land/std/fmt/colors.ts) module and works
similar to node's [chalk](https://github.com/chalk/chalk) module.

```typescript
import { colors } from "https://deno.land/x/cliffy/ansi/colors.ts";
Expand Down Expand Up @@ -197,7 +226,8 @@ $ deno run https://deno.land/x/cliffy/examples/ansi/color_themes.ts

## ❯ Contributing

Any kind of contribution is welcome! Please take a look at the [contributing guidelines](../CONTRIBUTING.md).
Any kind of contribution is welcome! Please take a look at the
[contributing guidelines](../CONTRIBUTING.md).

## ❯ License

Expand Down

0 comments on commit 821f13d

Please sign in to comment.