Skip to main content

Python binding for nil-clix: Opinionated Argument Parser

Project description

nil-clix

Python binding for nil-clix – an Opinionated Argument Parser

Links

Installation

pip install nil-clix

Usage

from nil_clix import create_node

node = create_node()

# Add flags
node.flag("verbose", "v", "Enable verbose output")

# Add parameters
node.param("config", "c", "Path to config file", fallback="config.yml")

# Add numbers
node.number("threads", "t", "Number of threads", fallback=4)

# Add handler
def handler(options):
    if options.flag("verbose"):
        print("Verbose mode enabled")
    config = options.param("config")
    threads = options.number("threads")
    print(f"Config: {config}, Threads: {threads}")
    return 0

node.use(handler)

# Run
exit_code = node.run(["-v", "-c", "my.yml", "-t", "8"])

Subcommands

from nil_clix import create_node

node = create_node()

def init_cmd(cmd):
    cmd.flag("force", "f", "Force initialization")

    def run_init(options):
        if options.flag("force"):
            print("Init: forced")
        else:
            print("Init: normal")
        return 0

    cmd.use(run_init)

node.sub("init", "Initialize the project", init_cmd)

exit_code = node.run(["init", "-f"])

Lifetime Notes

Root nodes are owning handles. The Python binding registers a GC finalizer so the underlying node is destroyed if the object is collected. Finalizer timing is nondeterministic and may not run at shutdown, so call destroy() for deterministic teardown. Subcommand nodes passed to callbacks are non-owning views and must not be stored or destroyed.

Documentation

For detailed API documentation and more examples, visit:

License

CC BY-NC-ND 4.0

Support

For issues, questions, or contributions, visit the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

nil_clix-1.0.10-py3-none-manylinux_2_39_x86_64.whl (174.7 kB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

nil_clix-1.0.10-py3-none-any.whl (174.4 kB view details)

Uploaded Python 3

File details

Details for the file nil_clix-1.0.10-py3-none-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for nil_clix-1.0.10-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 32be620f762e31b21203bf629b4a27c8932325ad6b5cf6457ebf2a2b63254c4f
MD5 a2d0c0c860999c136fc9a49a6d63fab3
BLAKE2b-256 7df662f5a5476e892d714b226491182237242015e12e9410391369ea1ea6a8a6

See more details on using hashes here.

File details

Details for the file nil_clix-1.0.10-py3-none-any.whl.

File metadata

  • Download URL: nil_clix-1.0.10-py3-none-any.whl
  • Upload date:
  • Size: 174.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for nil_clix-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 12951485de46ed6f855227e68e91b9021c1e88786dcd3079fb275dacc37172e3
MD5 4e2d8fee3a02ee62703a5499cd328cc0
BLAKE2b-256 00c34a4b1dd5453978c0fe8048bad2fb3fa744f4ffa1eca4ccdd6c1ee2051513

See more details on using hashes here.

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