Skip to content

ArchooD2/snaparg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  • Includes Interactive Mode which prompts for missing arguments to prevent immediate script failure and guide users smoothly.

📦 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.

About

snaparg is a lightweight wrapper around Python's built-in argparse library that adds automatic typo detection and helpful suggestions for command-line arguments. Instead of failing silently or throwing obscure errors, snaparg analyzes incorrect flags and proposes the closest valid alternatives.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages