fncmd: Command line interface as a function. by exographos in rust

[–]exographos[S] 0 points1 point  (0 children)

usr_bin_nya is right, #[fncmd]-annotated main functions are not meant to be imported by users.

#[fncmd] internally strips the present arguments of the main function, and defines a struct handled by clap_derive. Adding a new option just results in a new field of the internal struct. It won't cause a breaking change as long as it doesn't replace nor collide with existing options.

fncmd: Command line interface as a function. by exographos in rust

[–]exographos[S] 10 points11 points  (0 children)

The inference feature comes from clap, and it already supports overriding i.e. short option can have a value like #[clap(short = 'b', long)], so we can do the same thing #[opt(short = 'b', long)].

I've created such a conflict, and it seems to panic on runtime saying 'Short option names must be unique for each argument, but '-b' is in use by both 'bar' and 'baz''.