Skip to main content

An extension of argparse with history tracking

Project description

HistoryArgumentParser

Why Track Command History?

Have you ever found yourself wondering:

  • "What parameters did I use for that successful run last week?"
  • "How can I replicate the exact configuration from my previous experiments?"
  • "Is there an easy way to audit how my script has been used over time?"

HistoryArgumentParser is here to solve these problems and more!

What is HistoryArgumentParser?

HistoryArgumentParser is an extension of Python's built-in argparse.ArgumentParser that automatically tracks and stores the command-line arguments used in your scripts. It's designed to be a drop-in replacement for ArgumentParser, adding powerful history tracking capabilities with minimal changes to your existing code.

Key Features

  • 📜 Automatic command history tracking
  • 🕰️ Timestamped entries for easy reference
  • 🔍 Built-in history viewing functionality
  • 📁 Customizable history file location
  • 🔌 Seamless integration with existing argparse code

Installation

Install HistoryArgumentParser with pip:

pip install argparse_history

Quick Start

Replace your existing ArgumentParser with HistoryArgumentParser:

from history_argparse import HistoryArgumentParser

parser = HistoryArgumentParser(description="Your script description")
parser.add_argument('--input', help='Input file', required=True)
parser.add_argument('--output', help='Output file', required=True)

args = parser.parse_args()

# Your script logic here

That's it! Your script now tracks command history automatically.

Viewing Command History

To view the command history, simply run your script with the --show-history flag:

python your_script.py --show-history

This will display a list of previous runs with their timestamps and arguments.

Customizing History File Location

By default, the history is stored in the current directory. You can specify a custom directory:

python your_script.py --input in.txt --output out.txt --history-dir /path/to/history

Why Choose HistoryArgumentParser?

  1. Effortless Integration: Minimal changes to your existing code.
  2. Improved Reproducibility: Easily recreate previous runs.
  3. Better Debugging: Quickly identify what parameters were used in past executions.
  4. Audit Trail: Keep track of how and when your script is being used.
  5. Time-Saving: No more manual logging of script parameters.

Contributing

Your contributions are welcome! Please feel free to share if you use argparse_history and how it is useful to you. Also let me know if you have any suggestions of how it could serve you even better!

License

This project is licensed under the MIT License - see the LICENSE file for details. Start tracking your command history today with HistoryArgumentParser!

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

argparse_history-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

argparse_history-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file argparse_history-0.1.0.tar.gz.

File metadata

  • Download URL: argparse_history-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for argparse_history-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2c62e752ba1af5e1e1b9da567d2393dbc516586f38899492ce4e1f2747f48395
MD5 bdb894384544f4f14ddc4790d953e00a
BLAKE2b-256 677719ec1fd683ff9450b7e804cfeb7bce4a4004cfd8156c3792dadac7e3a83c

See more details on using hashes here.

File details

Details for the file argparse_history-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for argparse_history-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b92767b430cc428ae55c1e68f3c6af535fb0ef7de09ad1e3fb2f5191723c9b90
MD5 0ba3403f7c3cd6e2c909439b4810ee87
BLAKE2b-256 a18232435aa366bad7dd5b6fa735c3b696ccbc80364c85ddeaf5b3bc35f4474d

See more details on using hashes here.

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