Skip to content

[Feature]: Add Support for Custom Headers via CLI Flags #1

@dinocodesx

Description

@dinocodesx

Describe the feature you are requesting

Currently, Termino-Logistic allows users to specify request headers only within YAML/JSON configuration files. However, there is no way to define headers dynamically via command-line arguments.

💡 Proposed Feature:

  • Enable users to pass HTTP headers via CLI flags using the -H or --header option.
  • Allow multiple headers to be defined using the flag multiple times.
  • Ensure that CLI-defined headers override headers set in the request file (if there’s a conflict).

📝 Example Usage:

# Sending a GET request with custom headers
termino -f request.yml -H "Authorization: Bearer mytoken" -H "User-Agent: CustomClient/1.0"

Why is this feature needed?

  • Improves flexibility by allowing users to quickly modify headers without editing configuration files.
  • Useful for authentication (e.g., API keys, JWT tokens) where tokens may change frequently.
  • Enhances debugging and testing, as users can quickly test API responses with different headers.

Implementation Plan

1️⃣ Modify Argument Parser (main.py)

Update parse_args() in main.py to accept custom headers as CLI arguments:

ap.add_argument(
    "-H", "--header",
    action="append",
    help="Specify custom HTTP headers (use multiple times for multiple headers)"
)

This allows users to pass -H "Key: Value" multiple times.

2️⃣ Process Headers in Yeeter (feet.py)

Modify the yeet() method to:

  • Parse CLI headers into a dictionary.
  • Merge CLI headers with request file headers (CLI headers take precedence).
3️⃣ Update Help Documentation in README.md
  • Add an example of how to use the -H flag.
  • Clarify that CLI headers override request file headers if duplicated.

Additional Context

  • 🚀 This feature aligns with industry-standard CLI tools like curl, enhancing usability.
  • 🔥 Good First Issue for contributors familiar with Python, argparse, and API requests.

Would love feedback on the design! Feel free to contribute. 😃

Metadata

Metadata

Assignees

No one assigned

    Labels

    apertre2.0Issues and PRs created during Apertre EventenhancementNew feature or requestmediumA difficulty tag

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions