paper_firehose.core.command_context¶
Command context for shared initialization across CLI commands.
Provides a unified way to initialize config, database, and common parameters to reduce boilerplate code in command implementations.
Classes
|
Encapsulates shared initialization logic for CLI commands. |
- class paper_firehose.core.command_context.CommandContext(config_path=None)[source]¶
Bases:
objectEncapsulates shared initialization logic for CLI commands.
Handles config loading, validation, database connection, and topic resolution in a single reusable class to reduce boilerplate across commands.
Example
```python ctx = CommandContext(config_path) for topic in ctx.get_topics(topic_arg):
# Access ctx.config_manager, ctx.config, ctx.db entries = ctx.db.get_current_entries(topic=topic)
- Parameters:
config_path (Optional[str])
- get_nested_default(*keys, default=None)[source]¶
Get nested value from defaults section.
- Parameters:
- Return type:
- Returns:
Config value or default
Example
`python # Get config.defaults.abstracts.mailto mailto = ctx.get_nested_default('abstracts', 'mailto', default='noreply@example.com') `