CLI Operations
Relevant source files
The following files were used as context for generating this wiki page:
The CLI Operations for flext-tap-ldif provide the primary interface for executing the Singer Tap responsible for LDIF data extraction. This system leverages the FLEXT service facade to bridge command-line arguments to the underlying tap logic, enabling standardized interaction within ETL pipelines.
The entry point handles configuration loading, stream discovery, and record processing. It supports both modern FLEXT-standard execution and legacy Singer invocation methods to ensure compatibility with various orchestrators like Meltano.
Sources: src/flext_tap_ldif/cli.py:1-20, src/flext_tap_ldif/tap.py:12-25
Execution Architecture
The CLI follows a layered architecture where the command-line entry point delegates execution to a service facade, which in turn manages the lifecycle of the FlextTapLdif instance.
CLI Entry Points
The project exposes three distinct entry points via pyproject.toml to support different invocation styles:
flext-tap-ldif: The primary modern command.tap-ldif: A canonical alias for ease of use.tap-ldif-legacy: A direct entry point to the tap class for backward compatibility.
Sources: pyproject.toml:91-94
Call Flow Logic
When the CLI is invoked, the main function calls FlextTapLdifCli.run(). This class method instantiates a FlextTapLdifService and invokes cli_main(), passing along any provided string sequences as arguments.
The flow illustrates how command-line arguments are passed from the top-level script down to the service-managed tap execution.
Sources: src/flext_tap_ldif/cli.py:9-18, src/flext_tap_ldif/tap.py:18-20
Configuration and Command Parameters
The CLI operations are governed by a Pydantic-backed configuration model. Users provide settings via a JSON configuration file or environment variables (prefixed as defined in the project settings).
Available CLI Options
The following configuration properties are recognized during CLI execution:
| Property | Type | Default | Description |
|---|---|---|---|
file_path | string | N/A | Specific path to an LDIF file. |
directory_path | string | N/A | Path to a directory for bulk discovery. |
file_pattern | string | *.ldif | Glob pattern for finding files in a directory. |
encoding | string | utf-8 | File encoding used for reading LDIF content. |
strict_parsing | boolean | True | If true, fails the operation on parsing errors. |
max_file_size_mb | integer | 100 | Maximum allowed size for a single LDIF file. |
Sources: src/flext_tap_ldif/tap.py:20-40, src/flext_tap_ldif/_utilities/processor.py:27-31
Internal Data Flow
During a CLI run, the system transitions from configuration discovery to file processing. The Processor utility handles the filesystem interaction and yields records to the Singer stream.
The sequence diagram shows the interaction between the CLI facade, the Tap implementation, and the underlying file processor.
Sources: src/flext_tap_ldif/tap.py:46-52, src/flext_tap_ldif/_utilities/processor.py:53-76
Discovery and Processing Logic
- File Discovery: The CLI determines if a single
file_pathor adirectory_pathis provided. If a directory is used, it filters files byfile_patternandmax_file_size_mb. - Parsing: Each discovered file is read using the specified
encoding. TheProcessorutilizes theflext-ldiflibrary to transform raw text intoLdif.Entrymodels. - Standardization: Records are mapped to a Singer-compliant schema including DN (Distinguished Name), attributes, and metadata like
source_fileandline_number.
Sources: src/flext_tap_ldif/_utilities/processor.py:27-51, src/flext_tap_ldif/_utilities/processor.py:82-108
Summary
The CLI Operations for flext-tap-ldif encapsulate the complexities of LDIF parsing and filesystem traversal into a standard Singer Tap interface. By using the FlextTapLdifCli wrapper, the project ensures that all executions are routed through a consistent service layer, providing robust logging, error handling, and configuration validation.
Sources: src/flext_tap_ldif/cli.py:9-13, src/flext_tap_ldif/tap.py:18-20