This CLI tool manages repository configurations, allowing users to collect, store, and retrieve configuration settings for various projects and environments.
- Interactive and non-interactive configuration collection
- Storage of configurations in both JSON and ENV formats
- Support for local storage (future support for remote storage planned)
- Separation of core configuration (rpcfg) and application-specific (app) settings
- Environment variable generation for required settings
- Flexible configuration schema supporting various data types
To install the tool, clone the repository and build it using Cargo:
git clone https://github.com/yourusername/repo-config-cli.git
cd repo-config-cli
cargo build --release
cargo test
The binary will be available in target/release/rpcfg
.
The general syntax for using the tool is:
rpcfg [OPTIONS] <COMMAND>
init
: Initialize a new configuration filecollect
: Collect repository configurations and generate output filesdelete
: Delete generated output filesfetch
: Return the JSON config with the valuesshow
: Show the configuration table
-i, --input <FILE>
: Path to the input JSON file (global option)-s, --silent
: Use silent (non-interactive) mode (global option)--trace-level <LEVEL>
: Set the tracing level (off, error, warn, info, debug, trace) (global option, default: error)-h, --help
: Print help information-v, --version
: Print version information
-o, --output <FILE>
: Path to the output JSON file
-i, --input <FILE>
: Path to the input JSON file--ignore-timestamps
: Ignore timestamp checks and always collect
The primary input for this tool is a JSON configuration file. The file should have the following structure:
{
"rpcfg": [
{
"key": "config_version",
"description": "Version of the configuration",
"shellscript": "",
"default": "1.0",
"temp_environment_variable_name": "",
"required_as_env": false
},
{
"key": "project_name",
"description": "Name of the project",
"shellscript": "",
"default": "rpcfg",
"temp_environment_variable_name": "",
"required_as_env": false
},
{
"key": "config_name",
"description": "Name of the configuration",
"shellscript": "",
"default": "rpcfg_config",
"temp_environment_variable_name": "",
"required_as_env": false
},
{
"key": "environment",
"description": "Environment for the configuration",
"shellscript": "",
"default": "development",
"temp_environment_variable_name": "",
"required_as_env": false
}
],
"app": []
}
The tool generates two types of output files:
- JSON file: Contains the updated configuration data
- ENV file: Contains environment variables based on the configuration
The exact paths of these files are returned in the command result.
-
Initialize a new configuration file:
rpcfg init -o mysettings.json
-
Collect configuration in interactive mode:
rpcfg collect -i repo_config.json
-
Collect configuration, ignoring timestamps:
rpcfg collect -i repo_config.json --ignore-timestamps
-
Show configuration:
rpcfg show -i repo_config.json
-
Fetch configuration:
rpcfg fetch -i repo_config.json
-
Delete generated files:
rpcfg delete -i repo_config.json
The following table lists the main crates used in this project, along with their usage:
Crate | Modules | Usage |
---|---|---|
clap |
main.rs |
Command-line argument parsing |
anyhow |
Throughout | Error handling and propagation |
serde |
models.rs , main.rs |
JSON serialization and deserialization |
tracing |
Throughout | Logging and debugging |
tracing-subscriber |
main.rs |
Setting up the tracing subscriber |
uuid |
commands/collect.rs , test modules |
Generating unique identifiers for tests |
tabwriter |
commands/collect.rs , main.rs |
Formatting tabular output |
tempfile |
Test modules | Creating temporary files for testing |
std::fs |
Throughout | File system operations |
std::io |
Throughout | Input/output operations |
std::collections |
main.rs , commands/fetch.rs |
Using HashMap for data storage |
The project is structured into several modules:
main.rs
: Entry point and CLI setupmodels.rs
: Data structures for configurationcommands/
: Submodules for each command (init, collect, delete, fetch, show)
Each module uses a combination of these crates to implement its functionality, with error handling, logging, and serialization being common themes throughout the project.