Skip to content

Commit

Permalink
📚 doc: add description of command line tool
Browse files Browse the repository at this point in the history
  • Loading branch information
genkami committed Dec 28, 2020
1 parent 8e1a000 commit bb79711
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Watson makes it hard but fun to write configuration files.

## Index
* [Language Specification](./doc/spec.md)
* [CLI Tool(WIP)](#)
* [CLI Tool](./doc/cli.md)
* [pkg.go.dev](https://pkg.go.dev/github.com/genkami/watson)

## Installation
Expand Down
48 changes: 48 additions & 0 deletions doc/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# CLI Tool

All subcommands:

* [watson encode](#watson-encode)
* [watson decode](#watson-decode)

## watson encode

### Usage

```
watson encode -t=TYPE [-initial-mode=MODE] [FILE]
```

Converts `FILE` of type `TYPE` into Watson and outputs its Watson Representation to the standard output.

If `FILE` is not specified, it uses the standard input.

### Flags

| flag | mandatory | type | default | description |
| ---- | --------- | ---- | ------- | ----------- |
| **-t** | no | `json`, `yaml`, `msgpack`, or `cbor` | `yaml` | input file format |
| **-initial-mode** | no | `A` or `S` | `A` | initial mode of the lexer. see [the specification](./spec.md) for more details. |

## watson decode


### Usage

```
watson decode -t=TYPE [-initial-mode=MODE] [-stack-size=SIZE] [FILES...]
```

Converts Watson files `FILES` into another format that is specified by `TYPE` and outputs it to the standard output.

If `FILES` is not specified, it uses the standard input.

If multiple files are specified, they are executed sequencially by the same lexer and VM, that is, the mode of the lexer and the stack of the VM remains unchanged when the VM finished processing one file and continues to another. After processing the last file, a value at the top of the VM's stack is displayed.

### Flags

| flag | mandatory | type | default | description |
| ---- | --------- | ---- | ------- | ----------- |
| **-t** | no | `json`, `yaml`, `msgpack`, or `cbor` | `yaml` | input file format |
| **-initial-mode** | no | `A` or `S` | `A` | initial mode of the lexer. see [the specification](./spec.md) for more details. |
| **-stack-size** | no | integer | 1024 | stack size of the VM. see [the specification](./spec.md) for more details. |

0 comments on commit bb79711

Please sign in to comment.