Skip to content
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
38 changes: 8 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Tiny, simple, but powerful CLI framework for modern Go 🚀
- [Sub Commands](#sub-commands)
- [Flags](#flags)
- [Arguments](#arguments)
- [Shell Completion](#shell-completion)
- [Core Principles](#core-principles)
- [😱 Well behaved libraries don't panic](#-well-behaved-libraries-dont-panic)
- [🧘🏻 Keep it Simple](#-keep-it-simple)
Expand Down Expand Up @@ -331,33 +330,6 @@ The types you can currently use for positional args are:
> Slice types are not supported (yet), for those you need to use the `cmd.Args()` method to get the arguments manually. I plan to address this but it can be tricky
> as slice types will eat up the remainder of the arguments so I need to figure out a good DevEx for this as it could lead to confusing outcomes

### Shell Completion

`cli` has built-in support for shell completions via [carapace-bin]. Wire in `cli.CompletionSubCommand()` alongside your other subcommands:

```go
cmd, err := cli.New(
"mytool",
// ...
cli.SubCommands(
buildServeCommand,
buildDeployCommand,
cli.CompletionSubCommand(), // add this
),
)
```

Running `mytool completion` outputs a [carapace-spec] YAML document describing your full command tree — all subcommands, flags, and descriptions. Redirect it once to register completions with [carapace-bin]:

```shell
mytool completion > ~/.config/carapace/specs/mytool.yaml
```

carapace-bin then provides completions across bash, zsh, fish, nushell, PowerShell, and more — no shell-specific scripts required.

> [!TIP]
> See the [`./examples/completion`](https://github.com/FollowTheProcess/cli/tree/main/examples/completion) example for a working demonstration, and the [carapace-spec] docs for how to extend the generated YAML with semantic completion hints (file paths, environment variables, etc.)

## Core Principles

When designing and implementing `cli`, I had some core goals and guiding principles for implementation.
Expand Down Expand Up @@ -455,6 +427,14 @@ var delete bool
cli.New("demo", cli.Flag(&delete, "delete", cli.NoShortHand, "Delete something"))
```

## Gaps

`cli` is new and under active development, so naturally there are some gaps compared to more mature frameworks:

- No shell completion (yet): I'm thinking about some smart ways to achieve this and haven't made up my mind yet
- Man page generation: Similar to shell completion
- Text wrapping and terminal width detection for `--help` (currently this is on you to format when writing)

## In the Wild

I built `cli` for my own uses really, so I've quickly adopted it across a number of tools. See the following projects for some working examples in real code:
Expand All @@ -468,5 +448,3 @@ I built `cli` for my own uses really, so I've quickly adopted it across a number
[spf13/pflag]: https://github.com/spf13/pflag
[urfave/cli]: https://github.com/urfave/cli
[functional options]: https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
[carapace-bin]: https://github.com/carapace-sh/carapace-bin
[carapace-spec]: https://github.com/carapace-sh/carapace-spec
182 changes: 0 additions & 182 deletions completion.go

This file was deleted.

Loading
Loading