arcanis / clipanion

Type-safe CLI library / framework with no runtime dependencies
https://mael.dev/clipanion/
1.1k stars 61 forks source link

[Documentation] add cli examples #124

Open xenoterracide opened 2 years ago

xenoterracide commented 2 years ago

for example on https://mael.dev/clipanion/docs/paths

what is the command I would run? the reason I want this is I've been trying to figure out how to do --port, but from these docs I don't see what's obviously an example of that, there's this https://mael.dev/clipanion/docs/options but it doesn't show any examples of how to code those. I imagine it's on the previous page but it's hard to correlate the 2. Also, I don't see an example of how to create a command with no paths, although simply not defining paths seems to work. If I have an option, how do I pass it to a command?

class InstallCommand extends Command {
    static paths = [[`install`], [`i`]];
    async execute() {
        // ...
    }
}

also, https://mael.dev/clipanion/docs/contexts appears to be out of date, as BaseContext no longer contains some of that https://mael.dev/clipanion/docs/validation apply cascade signature is marked as deprecated

from the code I assumed this would create a port option, but it instead creates an argument

export class App extends Command {
  readonly port = Option.String({ validator: isPort, required: true })

  static readonly paths = [Command.Default]
❯ yarn workspace @cof/e1-fake-chamber-of-secrets run serve
Unknown Syntax Error: Unsupported option name ("--port").