Skip to main content

Check if argv has a specific flag

Project description

has-flag

Check if argv has a specific flag.

This is a port of the Node.js package has-flag to Python.

Quickstart

python3 -m pip install -U has-flag

(That strange-looking setup command is because I've found it to be the most reliable. The pip command often aliases to python 2, and pip3 often installs to the wrong Python package directory.)

Usage

from has_flag import has_flag

has_flag('unicorn');
#>>> True

has_flag('--unicorn');
#>>> True

has_flag('f');
#>>> True

has_flag('-f');
#>>> True

has_flag('foo=bar');
#>>> True

has_flag('foo');
#>>> False

has_flag('rainbow');
#>>> False
$ python3 foo.py -f --unicorn --foo=bar -- --rainbow

License

MIT

Contact

A library by Shawn Presser. If you found it useful, please consider joining my patreon!

My Twitter DMs are always open; you should send me one! It's the best way to reach me, and I'm always happy to hear from you.

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

has-flag-0.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

has_flag-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file has-flag-0.1.0.tar.gz.

File metadata

  • Download URL: has-flag-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.2 Darwin/20.3.0

File hashes

Hashes for has-flag-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f9fc5dd24e1c1a55a92d0baf5472a3fa80834cc7a977f7c2a2375d67175bce30
MD5 7239e8e4782d5c05d395b8151d612d18
BLAKE2b-256 4cf15b1f47f02b2175d6eeeb00500024a00dfe444f30949a551f95d25f8ab360

See more details on using hashes here.

File details

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

File metadata

  • Download URL: has_flag-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.2 Darwin/20.3.0

File hashes

Hashes for has_flag-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8756ff5768f29fc75f378fb91caaabde783b059b5c0eae5a57524a70df950a69
MD5 17eae1bcbb2692520c698bc92cfca4b0
BLAKE2b-256 583e1b9040555683ee2db3cdac25f76c75cb75c1ade017871228010e456e6d5d

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