Metadata-Version: 2.4
Name: MergeSourceFile
Version: 1.0.0
Summary: A Python tool to process SQL*Plus scripts, resolving file inclusions (@, @@) and variable substitutions (DEFINE/UNDEFINE)
Author: Alejandro G.
License-Expression: MIT
Project-URL: Homepage, https://github.com/alegorico/MergeSourceFile
Project-URL: Repository, https://github.com/alegorico/MergeSourceFile
Project-URL: Issues, https://github.com/alegorico/MergeSourceFile/issues
Keywords: sqlplus,sql,oracle,script-processor,file-merger
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: twine>=4.0.0; extra == "dev"
Requires-Dist: setuptools>=61.0; extra == "dev"
Requires-Dist: wheel>=0.40.0; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
Provides-Extra: build
Requires-Dist: pyinstaller>=5.0.0; extra == "build"
Dynamic: license-file

# MergeSourceFile 

A Python tool to process SQL*Plus scripts, resolving file inclusions and variable substitutions.

## Descripción

Este es un proyecto Python que incluye un script capaz de procesar scripts de SQL*Plus. El programa resuelve las inclusiones de archivos referenciados mediante `@` y `@@`, realiza sustituciones de variables definidas con `DEFINE`, soporta la eliminación de variables con `UNDEFINE`, y permite la redefinición de variables a lo largo del script.

## Features

- **File Inclusion Resolution**: Processes `@` and `@@` directives to include external SQL files
- **Variable Substitution**: Handles `DEFINE` and `UNDEFINE` commands for variable management
- **Variable Redefinition**: Supports redefining variables throughout the script
- **Tree Display**: Shows the inclusion hierarchy in a tree structure
- **Verbose Mode**: Detailed logging for debugging and understanding the processing flow

## Installation

```bash
pip install MergeSourceFile
```

## Usage

### Command Line

```bash
mergesourcefile --input input.sql --output output.sql
```

### Options

- `--input, -i`: Input SQL*Plus file to process (required)
- `--output, -o`: Output file where the result will be written (required)
- `--skip-var, -sv`: Skip variable substitution, only resolve file inclusions
- `--verbose, -v`: Enable verbose mode for detailed processing information

### Examples

1. **Process a SQL file with full processing**:
   ```bash
   mergesourcefile -i main.sql -o merged.sql
   ```

2. **Process only file inclusions, skip variable substitution**:
   ```bash
   mergesourcefile -i main.sql -o merged.sql --skip-var
   ```

3. **Process with verbose output**:
   ```bash
   mergesourcefile -i main.sql -o merged.sql --verbose
   ```

## How It Works

### File Inclusion

- `@filename`: Includes a file relative to the original base path
- `@@filename`: Includes a file relative to the current file's directory

### Variable Substitution

- `DEFINE varname = 'value';`: Defines or redefines a variable
- `&varname`: References a variable for substitution
- `&varname..`: Variable concatenation with period
- `UNDEFINE varname;`: Removes a variable definition

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Author

Alejandro G.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
