Clipanion provides three ways to handle arguments that are not tagged with flags:
- Positionals: Arguments that rely on a strict order. They can be required or optional.
- Rests: Arguments that accept an arbitrary amount of data. Unlike many frameworks, Clipanion allows you to place required positional arguments after a rest option.
- Proxies: Similar to rests, but they stop all further parsing once encountered. This is useful for commands that wrap other commands (e.g.,
yarn run).
Examples:
Rest option (aggregating everything following the command):
yarn add webpack webpack-cli
=> Command {"rest": ["webpack", "webpack-cli"]}
Rest option with trailing positionals (e.g., cp command):
cp src1 src2 src3 dest/
=> Command {"srcs": ["src1", "src2", "src3"], "dest": "dest/"}
Proxy option (stopping parsing to pass arguments to a sub-command):
yarn run foo --hello --world
=> Command {"proxy": ["--hello", "--world"]}