CLI Config
A simple library that provides utilities for managing configuration files in command-line applications.
Installation
To use this library in your project, add the following to your Cargo.toml
file:
[]
= "0.1"
By default this crate supports JSON. However, you can enable support for other file formats by using one or more of the following feature flags:
toml
: Enables support for TOML filesyaml
: Enables support for YAML files
If you need a custom implementation you can always implement the File
trait yourself and adapt it to your needs.
use File;
Usage
Here's an example of how to use this crate in order to manage config files:
use ;
In this example, we use the init
function to find the location of a configuration file named config.json
in a directory called my_cli_tool.
If the file doesn't exist, the function will create it and populate it with some default values.
We then load the contents of the file into a MyConfig
struct using the JSONFile
trait, and check to see if the user has run the program before.
License
This library is distributed under the terms of the MIT license. See LICENSE for details