Skip to content

Commit

Permalink
docs: update readmes (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed Aug 22, 2020
1 parent 6181747 commit 811e310
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 82 deletions.
32 changes: 30 additions & 2 deletions ansi-escape/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,35 @@
<sub>>_ Used by cliffy's <a href="../prompt/">prompt</a> module</sub>
</p>

## Usage
## ❯ Content

- [Install](#-install)
- [Usage](#-usage)
- [License](#-license)

## ❯ Install

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

Deno Registry

```typescript
import { AnsiEscape } from 'https://deno.land/x/cliffy@<version>/ansi-escape/mod.ts';
```

Nest Registry

```typescript
import { AnsiEscape } from 'https://x.nest.land/cliffy@<version>/ansi-escape/mod.ts';
```

Github

```typescript
import { AnsiEscape } from 'https://raw.githubusercontent.com/c4spar/deno-cliffy/<version>/ansi-escape/mod.ts';
```

## ❯ Usage

```typescript
#!/usr/bin/env -S deno run
Expand All @@ -49,6 +77,6 @@ AnsiEscape.from( Deno.stdout )
// ...
```

## License
## License

[MIT](../LICENSE)
71 changes: 48 additions & 23 deletions command/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
<sub>>_ Create flexible command line interfaces with type checking, auto generated help and out of the box support for shell completions </sub>
</p>

- [Usage](#usage)
- [Options](#options)
## ❯ Content

- [Install](#-install)
- [Usage](#-usage)
- [Options](#-options)
- [Common option types: string, number and boolean](#common-option-types-string-number-and-boolean)
- [List option types](#list-option-types)
- [Variadic options](#variadic-options)
Expand All @@ -42,31 +45,53 @@
- [Collect options](#collect-options)
- [Custom option processing](#custom-option-processing)
- [Option action handler](#option-action-handler)
- [Commands](#commands)
- [Commands](#-commands)
- [Argument syntax](#argument-syntax)
- [Action handler](#action-handler)
- [Executable sub-commands](#executable-sub-commands)
- [Global commands](#global-commands)
- [Hidden commands](#hidden-commands)
- [Stop early](#stop-early)
- [Override exit handling](#override-exit-handling)
- [Custom types](#custom-types)
- [Custom types](#-custom-types)
- [Function types](#function-types)
- [Class types](#class-types)
- [Global types](#global-types)
- [Environment variables](#environment-variables)
- [Add examples](#add-examples)
- [Auto generated help](#auto-generated-help)
- [Environment variables](#-environment-variables)
- [Add examples](#-add-examples)
- [Auto generated help](#-auto-generated-help)
- [Help option](#help-option)
- [Help command](#help-command)
- [Shell completion](#shell-completion)
- [Shell completion](#-shell-completion)
- [Completions command](#completions-command)
- [Zsh Completions](#zsh-completions)
- [Generic options and arguments](#generic-options-and-arguments)
- [Version option](#version-option)
- [License](#license)
- [Generic options and arguments](#-generic-options-and-arguments)
- [Version option](#-version-option)
- [License](#-license)

## ❯ Install

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

Deno Registry

```typescript
import { Command } from 'https://deno.land/x/cliffy@<version>/command/mod.ts';
```

Nest Registry

```typescript
import { Command } from 'https://x.nest.land/cliffy@<version>/command/mod.ts';
```

Github

```typescript
import { Command } from 'https://raw.githubusercontent.com/c4spar/deno-cliffy/<version>/command/mod.ts';
```

## Usage
## Usage

To create a program with cliffy you can import the `Command` class from the main module `https://deno.land/x/cliffy/command/mod.ts` or directly from the command module `https://deno.land/x/cliffy/command/command.ts`.

Expand All @@ -90,7 +115,7 @@ $ deno run https://deno.land/x/cliffy/examples/command/usage.ts --help

![](assets/img/usage.png)

## Options
## Options

Options are defined with the `.option()` method and can be accessed as properties on the options object which is passed to the `.action()` handler and returned by the `.parse()` method.

Expand Down Expand Up @@ -472,7 +497,7 @@ $ deno run https://deno.land/x/cliffy/examples/command/action-options.ts -i
Some info
```

## Commands
## Commands

The command class operates as a factory class. It has an internal command pointer which point per default to the command instance itself. Each time the `.command()` method is called, the internal pointer points to the newly created command. All methods such as `.name()`, `.description()`, `.option()`, `.action()`, etc... always work on the command to which the pointer points. If you need to change the pointer back to the command instance you can call the `.reset()` method.

Expand Down Expand Up @@ -740,7 +765,7 @@ $ deno run https://deno.land/x/cliffy/examples/command/override-exit-handling.ts
at <anonymous> (<anonymous>)
```

## Custom types
## Custom types

You can register custom types with the `.type()` method. The first argument is the name of the type, the second can be either a function or an instance of `Type` and the third argument can be an options object.

Expand Down Expand Up @@ -847,7 +872,7 @@ $ deno run https://deno.land/x/cliffy/examples/command/global-custom-type.ts log
{ email: "my@email.de" }
```

## Environment variables
## Environment variables

You can define environment variables for a command that are validated when the command is executed.
Environment variables are listed with the [help](#help-option-and-command) option and command.
Expand Down Expand Up @@ -877,7 +902,7 @@ $ SOME_ENV_VAR=abc deno run --allow-env --unstable https://deno.land/x/cliffy/ex
Error: Environment variable 'SOME_ENV_VAR' must be of type number but got: abc
```

## Add examples
## Add examples

You can add some examples for your command which will be printed with the [help](#help-option-and-command) option and command.

Expand All @@ -896,7 +921,7 @@ $ deno run https://deno.land/x/cliffy/examples/command/examples.ts help

![](assets/img/examples.png)

## Auto generated help
## Auto generated help

The help information is auto-generated based on the information you have defined on your command's.

Expand Down Expand Up @@ -982,7 +1007,7 @@ $ deno run https://deno.land/x/cliffy/examples/command/help-option-and-command.t
$ deno run https://deno.land/x/cliffy/examples/command/help-option-and-command.ts completions help
```

## Shell completion
## Shell completion

Cliffy supports shell completion out of the box.

Expand Down Expand Up @@ -1047,7 +1072,7 @@ To enable zsh completions on your system add the following line to your `~/.zshr
source <(command-name completions zsh)
```

## Generic options and arguments
## Generic options and arguments

> This is an experimental feature and may change in the future!
Expand Down Expand Up @@ -1080,7 +1105,7 @@ const input: string = result.args[ 0 ];
const output: string | undefined = result.args[ 1 ];
```

## Version option
## Version option

The `--version` and `-V` option flag prints the version number defined with the `version()` method. The version number will also be printed within the output of the [help](#help-option-command) option and command.

Expand Down Expand Up @@ -1130,10 +1155,10 @@ await new Command()
.parse( Deno.args );
```

## Credits
## Credits

Benjamin Fischer [@c4spar](https://github.com/c4spar)

## License
## License

[MIT](../LICENSE)
38 changes: 34 additions & 4 deletions flags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,37 @@
<sub>>_ Used by cliffy's <a href="../../command/">command</a> module</sub>
</p>

## Usage
## ❯ Content

- [Install](#-install)
- [Usage](#-usage)
- [Options](#-options)
- [Custom type processing](#-custom-type-processing)
- [License](#-license)

## ❯ Install

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

Deno Registry

```typescript
import { parseFlags } from 'https://deno.land/x/cliffy@<version>/flags/mod.ts';
```

Nest Registry

```typescript
import { parseFlags } from 'https://x.nest.land/cliffy@<version>/flags/mod.ts';
```

Github

```typescript
import { parseFlags } from 'https://raw.githubusercontent.com/c4spar/deno-cliffy/<version>/flags/mod.ts';
```

## ❯ Usage

```typescript
import { parseFlags } from 'https://deno.land/x/cliffy/flags/mod.ts';
Expand Down Expand Up @@ -107,7 +137,7 @@ $ deno run https://deno.land/x/cliffy/examples/flags/options.ts -vvv -n5 -f ./ex
}
```

## Options
## Options

### parseFlags Options

Expand Down Expand Up @@ -152,7 +182,7 @@ $ deno run https://deno.land/x/cliffy/examples/flags/options.ts -vvv -n5 -f ./ex

* `OptionType.BOOLEAN`

## Custom type processing
## Custom type processing

```typescript
import { parseFlags, IFlagOptions, IFlagArgument } from 'https://deno.land/x/cliffy/flags/mod.ts';
Expand All @@ -172,6 +202,6 @@ parseFlags( Deno.args, {
} );
```

## License
## License

[MIT](../LICENSE)
37 changes: 34 additions & 3 deletions keycode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,38 @@
<sub>>_ Used by cliffy's <a href="../prompt/">prompt</a> module.</sub>
</p>

## Usage
## ❯ Content

- [Install](#-install)
- [Usage](#-usage)
- [API](#-api)
- [KeyCode](#keycode)
- [KeyEvent](#keyevent)
- [License](#-license)

## ❯ Install

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

Deno Registry

```typescript
import { KeyCode } from 'https://deno.land/x/cliffy@<version>/keycode/mod.ts';
```

Nest Registry

```typescript
import { KeyCode } from 'https://x.nest.land/cliffy@<version>/keycode/mod.ts';
```

Github

```typescript
import { KeyCode } from 'https://raw.githubusercontent.com/c4spar/deno-cliffy/<version>/keycode/mod.ts';
```

## ❯ Usage

```typescript
import { KeyCode } from 'https://deno.land/x/cliffy/keycode/mod.ts';
Expand Down Expand Up @@ -66,7 +97,7 @@ await read();
$ deno run --unstable https://deno.land/x/cliffy/examples/keycode/read-key.ts
```

## Documentation
## ❯ API

### KeyCode

Expand All @@ -80,6 +111,6 @@ $ deno run --unstable https://deno.land/x/cliffy/examples/keycode/read-key.ts
* meta: boolean
* shift: boolean

## License
## License

[MIT](../../LICENSE)
19 changes: 10 additions & 9 deletions prompt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@

## ❯ Content

* [Install](#-install)
* [Usage](#-usage)
* [Single Prompt](#single-prompt)
* [Prompt List](#prompt-list)
* [Dynamic Prompts](#dynamic-prompts)
* [Custom Prompts](#custom-prompts)
* [API](#-api)
* [Types](#-types)
- [Install](#-install)
- [Usage](#-usage)
- [Single Prompt](#single-prompt)
- [Prompt List](#prompt-list)
- [Dynamic Prompts](#dynamic-prompts)
- [Custom Prompts](#custom-prompts)
- [API](#-api)
- [Types](#-types)
- [License](#-license)

## ❯ Install

Expand Down Expand Up @@ -577,6 +578,6 @@ The `Checkbox` prompt has all [base options](#base-options) and the following pr

**↑ back to:** [Prompt types](#-types)

## License
## License

[MIT](../LICENSE)
Loading

0 comments on commit 811e310

Please sign in to comment.