Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Sep 15, 2024
1 parent 96f3e90 commit e650bbe
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 25 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,17 @@ dependencies {
}
```

There is also a smaller core module available. [See the docs for details](https://ajalt.github.io/clikt/advanced/#core-module).


###### If you're using Maven instead of Gradle, use `<artifactId>clikt-jvm</artifactId>`

#### Multiplatform

Clikt supports the following targets: `jvm`, `mingwX64`, `linuxX64`, `linuxArm64`, `macosX64`, `macosArm64`,
and `js` and `wasmJs` (for both Node.js and Browsers). [See the
docs](https://ajalt.github.io/clikt/advanced/#multiplatform-support) for more information about
functionality supported on each target. You'll need to use Gradle 6 or newer.
Clikt supports most multiplatform targets.
[See the docs](https://ajalt.github.io/clikt/advanced/#multiplatform-support)
for more information about functionality supported on each target. You'll need to use Gradle 6 or
newer.

#### Snapshots

Expand Down
33 changes: 14 additions & 19 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,35 +608,29 @@ abstract class MyCoreCommand : CoreCliktCommand() {

## Multiplatform Support

Clikt supports the following platforms in addition to JVM:
Clikt supports the following platforms:

### Desktop native (Linux, Windows, and macOS)

All functionality is supported, except:

* `env` parameter of [editText][editText] and [editFile][editFile] is ignored.
* [file][file] and [path][path] parameter types are not supported.
### JVM

### NodeJS JavaScript and WasmJS
There are some JVM-only extensions available such as [file][file] and [path][path] parameter types.

All functionality is supported, except:

* [file][file] and [path][path] parameter types are not supported.
### Desktop native (Linux, Windows, and macOS)

### Browser JavaScript and WasmJS
### JavaScript and WasmJS

All functionality is supported, except:
All functionality is supported on Node.js.

* The default terminal only outputs to the browser's developer console, which is
probably not what you want. You can [define your own
In the browser, the default terminal only outputs to the browser's developer
console, which is probably not what you want. You can [define your own
TerminalInterface](#replacing-stdin-and-stdout), or you can call [parse][parse] instead of
[main][main] and handle output yourself.
* [editText][editText] and [editFile][editFile] are not supported.
* [file][file] and [path][path] parameter types are not supported.

### iOS, watchOS, tvOS and wasmWasi
### iOS

### watchOS, tvOS and WasmWasi

These platforms are supported for the [core module](#core-module) only.
These platforms are not supported by the [markdown module], but all other functionality is
available.

[BaseCliktCommand]: api/clikt/com.github.ajalt.clikt.core/-base-clikt-command/index.html
[CliktCommand]: api/clikt-mordant/com.github.ajalt.clikt.core/-clikt-command/index.html
Expand All @@ -662,6 +656,7 @@ These platforms are supported for the [core module](#core-module) only.
[file]: api/clikt/com.github.ajalt.clikt.parameters.types/file.html
[grouping-options]: documenting.md#grouping-options-in-help
[main]: api/clikt/com.github.ajalt.clikt.core/main.html
[markdown module]: documenting.md#markdown-in-help-texts
[parse]: api/clikt/com.github.ajalt.clikt.core/parse.html
[path]: api/clikt/com.github.ajalt.clikt.parameters.types/path.html
[prompt]: options.md#prompting-for-input
Expand Down
58 changes: 56 additions & 2 deletions docs/migration.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
# Upgrading to Newer Releases

See the [changelog] for a full list of changes in each release. This guide contains information on
the most significant changes that may require updating to your code.

## Upgrading to 5.0

## `main` is now an extension
## some methods like `main` are now extensions

The `CliktCommand.main` and `CliktCommand.parse` methods are now a extension functions, so you'll
The `CliktCommand.main` and `CliktCommand.parse` methods are now extension functions, so you'll
need to import them.

```diff
+ import com.github.ajalt.clikt.core.main
fun main(args: Array<String>) = MyCommand().main(args)
```

`Context.obj` and `Context.terminal`, and `OptionTransformContext.terminal` are also now extensions.

```diff
+ import com.github.ajalt.clikt.core.obj
+ import com.github.ajalt.clikt.core.terminal

fun main() {
val ctx = MyCommand().currentContext
ctx.terminal.info(ctx.obj)
}
```


## `CliktCommand` constructor no longer takes most parameters

All parameters of the `CliktCommand` except for `name` have been moved to open properties.
Expand Down Expand Up @@ -62,6 +78,44 @@ The full list of moved parameters:
| `treatUnknownOptionsAsArgs` | `val treatUnknownOptionsAsArgs` |
| `hidden` | `val hiddenFromHelp` |

### Markdown moved to a separate module

In order to reduce executable size, the Markdown rendering functionality has been moved to a separate
module.

To use Markdown rendering first, add the `:clitk-markdown` dependency to your project:

```kotlin
dependencies {
implementation("com.github.ajalt.clikt:clikt-markdown:$cliktVersion")
}
```

Then install the markdown help formatter on your command:

```kotlin
val command = MyCommand().installMordantMarkdown()
```


### `Context` builder properties renamed

Some of the properties on `Context` and its builder have been renamed to be more consistent:

| old name | new name |
|-------------------------------|---------------------------------|
| `Context.envvarReader` | `Context.readEnvvar` |
| `Context.correctionSuggestor` | `Context.suggestTypoCorrection` |
| `Context.argumentFileReader` | `Context.readArgumentFile` |
| `Context.tokenTransformer` | `Context.transformToken` |

The old names are still available as deprecated properties.

### Removed `TermUi`

The remaining methods in `TermUi` have been removed. If you were using it, you can open an editor
manually with `ProcessBuilder` or similar.

## Upgrading to 4.0

### Help formatting
Expand Down
4 changes: 4 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ inside a [`CliktCommand`][CliktCommand]. The normal way to use Clikt is to forwa
The simplest command with no parameters would look like this:

```kotlin
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.main

class Hello: CliktCommand() {
override fun run() {
echo("Hello World!")
Expand Down Expand Up @@ -67,6 +70,7 @@ class Hello : SuspendingCliktCommand() {

suspend fun main(args: Array<String>) = Hello().main(args)
```

## Nesting Commands

Instances of any command can be attached to other commands, allowing
Expand Down

0 comments on commit e650bbe

Please sign in to comment.