Skip to main content

A typo-tolerant CLI parser wrapper for argparse

Project description

GitHub commit activity GitHub contributors GitHub last commit PyPI - License PyPI - Downloads

snaparg – Smarter argparse for easy living

snaparg is a lightweight Python library that wraps around the built-in argparse module, making command-line interfaces more user-friendly by detecting typos in argument names and suggesting the closest valid alternatives.

Perfect for scripts and tools that aim to be a little more forgiving to users without sacrificing the power and flexibility of argparse.

You can even replace it in any script just by editing your import statement!


✨ Features

  • Drop-in replacement for argparse.ArgumentParser
  • Detects mistyped CLI flags and suggests corrections
  • Compatible with existing argparse-based code
  • Zero dependencies — works out of the box

📦 Quick Start

  • pip install snaparg

  • then replace:

  • from argparse import ArgumentParser -> from snaparg import SnapArgumentParser as ArgumentParser


🔧 Example

$ python demo.py --iput file.txt
Error: Unknown or invalid argument(s).
  Did you mean: '--iput' -> '--input'?

Full message:
usage: demo.py [-h] [--input INPUT] [--output OUTPUT] [--force]

📄 License

This project is licensed under the Mozilla Public License 2.0 (MPL-2.0). See the LICENSE file for details.

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

snaparg-0.2.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snaparg-0.2.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file snaparg-0.2.0.tar.gz.

File metadata

  • Download URL: snaparg-0.2.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for snaparg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c4be6aea9464dd6ecab3f98dd080b2889f53b75a1d6c44f3d46991c8a295c207
MD5 7567a764509aa29943b76473fd6abba4
BLAKE2b-256 006443ea28df5ba169ee71b013e3c06f59be382a9744b6a5894afa7cf86cb532

See more details on using hashes here.

Provenance

The following attestation bundles were made for snaparg-0.2.0.tar.gz:

Publisher: python-publish.yml on ArchooD2/snaparg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snaparg-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: snaparg-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for snaparg-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54770761410d852d0f64760c956404e04b790619330b243cd33d932eaa606daa
MD5 42e404b692885789f5eb7473b1ecbb61
BLAKE2b-256 369a5aee554ac04352291837bca455ccc52a397e44eb4ff0309b22a5d7e5d53f

See more details on using hashes here.

Provenance

The following attestation bundles were made for snaparg-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on ArchooD2/snaparg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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