init64 / octoffers

Octoffers is a tool that automatically hunts down suitable jobs and applies for you on major job boards.
https://octoffers.click
BSD 3-Clause "New" or "Revised" License
17 stars 0 forks source link

Refactoring CLI and Core Functionality #2

Closed webgtx closed 6 months ago

webgtx commented 7 months ago

Subject: CLI Refactoring Approach and Library Selection for Octoffers Python Migration

As we embark on the critical task of refactoring the Command-Line Interface (CLI) and core functionality of Octoffers for the Python migration, it is imperative to choose a library that aligns with our project goals of simplicity, maintainability, and user-friendliness. After careful consideration, I propose the following libraries for your review:

  1. Click:

    • Overview: Click is a widely-adopted Python package renowned for creating elegant and user-friendly command-line interfaces. Its declarative syntax and automatic help page generation make it a strong contender for our refactoring efforts.

    • Advantages:

      • Clear syntax for defining commands and options.
      • Automatic generation of help pages.
      • Support for intricate command structures.
    • Example:

      import click
      
      @click.command()
      @click.option('--resume', help='Path to the resume file')
      @click.option('--cover-letter', help='Path to the cover letter file')
      def submit_job_application(resume, cover_letter):
       """Submit job application with resume and cover letter."""
       # Implementation resides here
      
      if __name__ == '__main__':
       submit_job_application()
  2. Fire:

    • Overview: Fire, developed by Google, offers automatic CLI generation from existing Python code. It's particularly useful for projects where simplicity and quick implementation are crucial.

    • Advantages:

      • Minimal code required for CLI implementation.
      • CLI generation based on function signatures.
    • Example:

      import fire
      
      def submit_job_application(resume, cover_letter):
       """Submit job application with resume and cover letter."""
       # Implementation resides here
      
      if __name__ == '__main__':
       fire.Fire(submit_job_application)
  3. Typer:

    • Overview: Typer is a fast and user-friendly library for building command-line applications, built on top of Click. It supports type hints, providing automatic type checking and interactive help message generation.

    • Advantages:

      • Automatic type checking using Python type hints.
      • Interactive help message generation.
    • Example:

      import typer
      
      def submit_job_application(resume: str, cover_letter: str):
       """Submit job application with resume and cover letter."""
       # Implementation resides here
      
      if __name__ == '__main__':
       typer.run(submit_job_application)

Please review these options, considering the project's requirements and our collective development preferences. Your feedback and insights are invaluable as we strive to enhance the Octoffers CLI in our Python migration.

webgtx commented 7 months ago

I've decided to use fire as the main cli library

webgtx commented 6 months ago

The best thing about fire as cli library

You don't have to build any boilerplates for arguments, or help infromation. Everything is auto-generated from classes and functions. So far, this library has made the migration to python a good decision.

webgtx commented 6 months ago

It's done

The CLI has been refactored, with necessary core features