Hello I want to implement customisation to swift argumentparser, Here are following changes want to do it in my cli
changing default footer present in help command output
currently help command output coming like this
OVERVIEW: clisample
USAGE: clisample <subcommand>
OPTIONS:
--version show the version.
-h, --help show the help.
SUBCOMMANDS:
logs (default) Export logs for clisample processes.
See 'clisample --help' for more information.'`
so instead of See 'clisample --help' for more information.' I want For more details, run 'clisample help <subcommand>'
customise error string getting from validation error
currently output of error
Error: Missing value for '-t <time>
Help: -t <time> Time window (e.g. 10h, 30m, 2d).
Usage: clisample logs --time <time>
See 'clisample logs --help' for more information.
so I want error output with example and customised footer, like this
Error: Missing value for '-t <time>'
Help: -t <time> Time window (e.g. 10h, 30m, 2d).
Usage: clisample logs --time <time>
Example: clisample logs -t 5m
For more details, run 'clisample help <subcommand>'
If this feature is already available, please guide me, as i haven't seen anything on forums and any other place
That level of customization isn't currently present in ArgumentParser. To support that we would probably need some kind of templating system, which isn't part of the library.
That said, you can intercept all the help and error output if you implement your own @main type. The static func main() implementation is fairly simple (you can copy from here) and you could post-process the error text by passing any errors you catch to your command's fullMessage(for:) method: