Skip to content

Generate a config parser from a clap argument parser

Notifications You must be signed in to change notification settings

casey/clap-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This might be out of scope of the clap project, but I think it would be pretty neat.

Many programs wind up configuring themselves both from command line options and from a config file. A lot of the time there is a lot of overlap, with options being configurable in both. Other times there are accidental omissions, where something that should be configurable on the command line can only be configured in a config file, or vice versa.

It would be pretty awesome if clap would generate a simple YAML or TOML config parser based on the command line options, and then allow pulling options from that or in addition to the command line.

Lots of things wouldn't make sense, for example subcommands, but the majority of things probably would.

Also, since YAML or TOML are typed languages, type restrictions would be easy to enforce.

I wrote up a quick sketch of how I imagine it looking. The interesting files are:

  • src/main.rs: Create a clap::App and load matches from config file
  • src/ExampleConfig.coml: An example config file

About

Generate a config parser from a clap argument parser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages