Replies: 3 comments 4 replies
-
I think I would need to see an example of the config file you want to support to answer for certain. Sub commands or option groups can be triggered multiple times to handle an array like structure. Or it might make sense to make your own parser customization to handle things a little cleaner. |
Beta Was this translation helpful? Give feedback.
-
After some further analysis of the CLI11 lib, I couldn't find a clean way to support lists of objects using just options, subcommands or option groups. I assume that, at this stage, the feature is not supported. This is likely because the lib is primarily designed with command-line argument parsing in mind (rather than config file parsing) and lists of objects are something hard to configure via the command line. I guess the follow-up question would be if there is an easy way to customize the format output for a single option (in this case, my list of objects). My idea would be that, in the case that the option is a list of objects, I could have a custom formatter that prints each subfield of the object type. |
Beta Was this translation helpful? Give feedback.
-
I poked at it a little, When I have had config files that had objects what I did in the past was ran all the normal flags and fields through CLI11. Then just parsed the file directly to extract the array of structures either as an entirely separate parse of CLI11 or just completely outside of it. There isn't really a good way of handing arrays of identical structures in CLI11 at present. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have a quite complicated configuration setup, consisting of a relatively large config file, and I like to override the parameters in this config file with parameters I pass through the command line. CLI11 seems perfect for this.
However, I run into a problem, which I don't know how to solve. My configuration file contains some arrays of objects (lists where each item has its own subfields) and I don't know how to parse these arrays via CLI11. Is this feature supported at all?
I thought of converting my array of objects into several subcommands, but that would require specifying a limit for the array, and it would make the
--help
look ugly. e.g.If this feature is not supported, is there a plan to do so? I wouldn't even mind if these arrays of objects were not configurable through the command line, as long as they would get parsed by CLI11 when set in the configuration file.
Beta Was this translation helpful? Give feedback.
All reactions