Metadata-Version: 2.4
Name: nil_clix
Version: 1.0.11
Summary: Python binding for nil-clix: Opinionated Argument Parser
License: CC BY-NC-ND 4.0
Project-URL: Homepage, https://github.com/njaldea/nil-clix
Project-URL: Repository, https://github.com/njaldea/nil-clix
Project-URL: Documentation, https://github.com/njaldea/nil-clix/blob/master/src/ffi/python/README.md
Keywords: nil,cli,commandline
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# nil-clix

Python binding for **nil-clix** – an Opinionated Argument Parser

## Links

- **Repository:** https://github.com/njaldea/nil-clix
- **C API Documentation:** https://github.com/njaldea/nil-clix/blob/master/docs/c-api.md

## Installation

```bash
pip install nil-clix
```

## Usage

```python
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

```python
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:
- [C++ Documentation](https://github.com/njaldea/nil-clix)
- [C API Guide](https://github.com/njaldea/nil-clix/blob/master/docs/c-api.md)

## License

CC BY-NC-ND 4.0

## Support

For issues, questions, or contributions, visit the [GitHub repository](https://github.com/njaldea/nil-clix).
