Skip to main content

Convert Python's default argparse into typer CLI

Project description

argparse2typer

Use case

  • Do you ever need to work on an open source project and find that they use argparse? Nothing's wrong with argparse but you have already been falling in love with typer CLI (you all will someday)?
  • Fear no more, just use argparse2typer and all the argparse code would be parsed into typer CLI with as little changes as possible.

Installation

  • With pip:
pip install argparse2typer

Usage

  1. Locate the line args = parser.parse_args() in the original script
  2. Import the function from argparse2typer import argparse2typer
  3. Run the function before parse_args:
argparse2typer(parser=parser, output_path=Path(<path>)) # <- new line
args = parser.parse_args()
  1. New file @ will be created with the typer CLI format!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

argparse2typer-0.0.2.tar.gz (16.7 kB view hashes)

Uploaded Source

Built Distribution

argparse2typer-0.0.2-py3-none-any.whl (16.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page