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.11-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.11-py3-none-any.whl (174.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for nil_clix-1.0.11-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 ccaff9574f173658ec2fd42f1f84b52359c5fac43fd081e9e567704f1bf35844
MD5 e9663ab5b17a3b2767af6c8572909067
BLAKE2b-256 bfe3c379884c0fc52b722807bd6cbb58faca706430b334cfcbd8f8adf2776c4c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nil_clix-1.0.11-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.11-py3-none-any.whl
Algorithm Hash digest
SHA256 610586dbe9f749d22b7ead4647c13486361038aeaa83608d5f0c06a56fa617ea
MD5 f25b255d4c2aec4cf5097312bb60a0ce
BLAKE2b-256 9a7e64b831fb973e358ae7c012990b1d46df49da1c4707925e0ffd95ff4de4c0

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