flagparse is library to build command-line interfaces
Project description
Flagparse
Flagparse is a library for building modular command-line interfaces with accent on nested commands. This library removes the pain of manually constructing the argument parsing and applying handler for each command, all of this is done by this tiny library.
Installation
pip install flagparse
Usage and documentation
Please see the wiki for basic usage and other documentation of using flagparse.
Here is an example of a simple Flagparse app:
import flagparse class Sum(flagparse.SubCommand): """Sub-command to handle numbers summation.""" name = "sum" arguments = [ (["integers"], dict(metavar="INT", type=int, nargs="+", help="integers to be summed")), ] def handle(self, args: flagparse.Namespace) -> None: print(sum(args.integers)) class Calc(flagparse.Command): """A simple calculator that sums numbers.""" name = "calc" if __name__ == "__main__": Calc(subcommands=[Sum]).parse()
How it looks when run:
$ python main.py sum 1 2 3 6
License
The openflow library is distributed under MIT license, therefore you are free to do with code whatever you want. See the LICENSE file for full license text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size flagparse-0.0.3-py2.py3-none-any.whl (4.9 kB) | File type Wheel | Python version py2.py3 | Upload date | Hashes View |
Filename, size flagparse-0.0.3.tar.gz (3.9 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for flagparse-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 000d71d35e556a30c49515889c0d10b4f9acb4ef398e0452d132f54648230b99 |
|
MD5 | 4dbe45fa9f496a3c04534b99eb3667c6 |
|
BLAKE2-256 | f756aab593b71df9fbde91e6349875b098e9d8198d79ebe4c4b2749b1959f9b5 |