Subversion Repositories perlutils

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 rodolico 1
# perlConfigFileUtility
2
 
3
A Perl utility for managing configuration files with template merging, interactive editing, and format conversion capabilities.
4
 
5
## Overview
6
 
7
`perlConfigFileUtility` is designed to simplify configuration file management by:
8
- Merging template structures with existing configuration files
9
- Providing an interactive hierarchical editor for modifying configurations
10
- Converting between YAML and JSON formats
11
- Automatically backing up config files when saving changes
12
 
13
## Background
14
 
15
This utility solves two primary problems:
16
 
17
1. **User-Friendly Editing**: Enables users unfamiliar with JSON/YAML syntax to safely edit configuration files through an interactive interface.
18
 
19
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.
20
 
21
### Implementation Approach
22
 
23
- Default configuration is stored as a Perl data structure in a separate file (loaded via `do` statement in project script)
24
- This template can be shared across multiple applications
25
- The utility loads existing YAML/JSON configs, merges missing values from the template, and presents an interactive editor
26
- Format conversion (YAML ↔ JSON) was added as a natural extension of the merge functionality
27
 
28
## Features
29
 
30
- **Template Merging**: Combine Perl data structure templates with existing YAML/JSON config files
31
- **Interactive Editor**: Navigate and edit nested hashes and arrays with a menu-driven interface
32
- **Dynamic Modifications**: Add new keys to hashes and elements to arrays on the fly
33
- **Delete Operations**: Remove keys from hashes and elements from arrays, including all nested children
34
- **Format Conversion**: Seamlessly convert between YAML and JSON configuration formats
35
- **Safe Updates**: Automatic backup creation before saving changes
36
 
37
## Usage
38
 
39
```bash
40
# Basic usage
41
perlConfigFileUtility [-t <template_file>] [-c <config_file>] [-o <output_file>] [-e]
42
 
43
# Positional arguments (backward compatibility)
44
perlConfigFileUtility <template_file> [config_file]
45
```
46
 
47
## Options
48
 
49
| Option | Description |
50
|--------|-------------|
51
| `-t, --template <file>` | Template file (Perl hashref) |
52
| `-c, --config <file>` | Config file (YAML or JSON) |
53
| `-o, --output <file>` | Output file (default: STDOUT) |
54
| `-e, --edit` | Interactive edit mode |
55
| `-v, --version` | Show version information |
56
| `-h, --help` | Show help message |
57
 
58
## Requirements
59
 
60
- **Perl** 5.x or higher
61
- **File::Slurp** - File reading utilities
62
- **Data::Dumper** - Data structure serialization
63
- **Getopt::Long** - Command-line option parsing
64
 
65
## License
66
 
67
Simplified BSD License (FreeBSD License)  
68
Copyright (c) 2026, Daily Data Inc.
69
 
70
## Author
71
 
72
R. W. Rodolico <rodo@dailydata.net>
73
 
74
## Version
75
 
76
1.1.0 (January 2026)
77
 
78
### Version History
79
 
80
- **1.1.0** (2026-01-15): Added ability to delete keys from hashes and elements from arrays
81
- **1.0** (2026-01-13): Initial release with merge, edit, and format conversion capabilities