Skip to main content

Flag library

Simple flag processing for Python

Supported types:

type implemented
int True
float True
str True
bool True
list True
custom True

Installation

$ pip install easy-flagger

Simple usage example

# python example.py -f 10.3
from flagger import Flagger

if __name__ == "__main__":
    flag = Flagger()
    f_flag = flag.parse_flag("-f", float)

    print(f_flag) # >> 10.3

List usage example

# python example.py -l 1,2,3
from flagger import Flagger

if __name__ == "__main__":
    flag = Flagger()
    l_flag = flag.parse_flag("-l", list, sep=",")

    print(l_flag) # >> ['1', '2', '3']

Checks flag for existence example

# python example.py --flag
from flagger import Flagger

if __name__ == "__main__":
    flag = Flagger()
    l_flag = flag.parse_flag("--flag")

    print(l_flag) # >> True

Using custom types flags

# python example.py -e Aerendyl
from flagger import Flagger

class Elven:
    allowed = {
        "aerendyl": 1,
        "erendriel": 2,
        "galadriel": 3
    }
    
    @staticmethod
    def check(value: str):
        value = value.lower()
        is_allowed = value in Elven.allowed
        if not is_allowed:
            raise ValueError("the language is that of Mordor, which I will not utter here")
        
        return Elven.allowed.get(value) 

if __name__ == "__main__":
    flag = Flagger()
    flagger.types.add_parser(Elven, Elven.check)
    
    elf = flagger.parse_flag("-e", Elven)
    
    print(elf) # >> Aerendyl

Metadata

Release files for easy-flagger 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-flagger 2.0.0
File Size Uploaded
easy_flagger-2.0.0.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easy-flagger 2.0.0
File Interpreter ABI Platform
easy_flagger-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / easy_flagger-2.0.0.tar.gz

Download URL easy_flagger-2.0.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e16c86b61bdc05469568059cf3da7466776050097ef1077850e73958eb02b316
BLAKE2b-256 checksum
How to use checksums
0b814f55b75d3452be4919a6de8ba11944a445a4e602bb557e056a72acd82ab1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2025.

Transparency log

Release files / easy_flagger-2.0.0-py3-none-any.whl

Download URL easy_flagger-2.0.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bb71239b5a3f4797d420a4914058664b84b159bfc9be14ab505d56ae4da69cf
BLAKE2b-256 checksum
How to use checksums
8e134678d989769b1eb59742e1dfe4e59c3b57d73b344007c9933a6f6d788bfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.0

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page