Subversion Repositories perlutils

Rev

Rev 3 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

# perlConfigFileUtility

A Perl utility for managing configuration files with template merging, interactive editing, and format conversion capabilities.

## Overview

`perlConfigFileUtility` is designed to simplify configuration file management by:
- Merging template structures with existing configuration files
- Providing an interactive hierarchical editor for modifying configurations
- Converting between YAML and JSON formats
- Automatically backing up config files when saving changes

## Background

This utility solves two primary problems:

1. **User-Friendly Editing**: Enables users unfamiliar with JSON/YAML syntax to safely edit configuration files through an interactive interface.

2. **Version Compatibility**: Handles configuration file evolution across software versions. When new key/value pairs are added to the application, the utility merges them with existing config files, ensuring older configurations remain compatible with newer software.

### Implementation Approach

- Default configuration is stored as a Perl data structure in a separate file (loaded via `do` statement in project script)
- This template can be shared across multiple applications
- The utility loads existing YAML/JSON configs, merges missing values from the template, and presents an interactive editor
- Format conversion (YAML ↔ JSON) was added as a natural extension of the merge functionality

## Features

- **Template Merging**: Combine Perl data structure templates with existing YAML/JSON config files
- **Interactive Editor**: Navigate and edit nested hashes and arrays with a menu-driven interface
- **Dynamic Modifications**: Add new keys to hashes and elements to arrays on the fly
- **Delete Operations**: Remove keys from hashes and elements from arrays, including all nested children
- **Format Conversion**: Seamlessly convert between YAML and JSON configuration formats
- **Safe Updates**: Automatic backup creation before saving changes

## Usage

```bash
# Basic usage
perlConfigFileUtility [-t <template_file>] [-c <config_file>] [-o <output_file>] [-e]

# Positional arguments (backward compatibility)
perlConfigFileUtility <template_file> [config_file]
```

## Options

| Option | Description |
|--------|-------------|
| `-t, --template <file>` | Template file (Perl hashref) |
| `-c, --config <file>` | Config file (YAML or JSON) |
| `-o, --output <file>` | Output file (default: STDOUT) |
| `-e, --edit` | Interactive edit mode |
| `-v, --version` | Show version information |
| `-h, --help` | Show help message |

## Requirements

- **Perl** 5.x or higher
- **File::Slurp** - File reading utilities
- **Data::Dumper** - Data structure serialization
- **Getopt::Long** - Command-line option parsing

## License

Simplified BSD License (FreeBSD License)  
Copyright (c) 2026, Daily Data Inc.

## Author

R. W. Rodolico <rodo@dailydata.net>

## Version

1.1.0 (January 2026)

### Version History

- **1.1.0** (2026-01-15): Added ability to delete keys from hashes and elements from arrays
- **1.0** (2026-01-13): Initial release with merge, edit, and format conversion capabilities