Skip to content

Refactor CLI Module for Better Maintainability #137

@PaperMtn

Description

@PaperMtn

Problem

The current cli.py is a large monolithic file (4000+ lines) that handles all command-line functionality. This makes it difficult to:

  • Maintain and update specific commands
  • Add new commands without increasing complexity
  • Onboard new developers to add new functionality

Proposed Changes

Refactor the CLI module into a modular structure:

src/secops/cli/
├── __init__.py
├── __main.py__            # Main CLI entry point
├── commands/             # Command handlers
│   ├── __init__.py
│   ├── config.py         # Config commands
│   ├── search.py         # Search commands
│   ├── rule.py           # Rule management
│   ├── feed.py           # Feed management
│   ├── export.py         # Data export
│   ├── data_table.py     # Data table operations
│   ├── reference_list.py # Reference list operations
│   └── ...               # etc.
└── utils/                # Shared utility functions
    ├── __init__.py
    ├── formatters.py  
    ├── config_utils.py     
    └── time_utils.py     

Key Benefits:

  • Improved Maintainability: Smaller, focused files are easier to understand and modify
  • Better Organisation: Logical grouping of related functionality
  • Faster Development: New commands can be added without navigating a large file

Migration:

  • Backward compatibility will be maintained
  • Existing scripts using secops.cli will continue to work
  • New code should use the modular structure

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions