Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flagparse

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flagparse

flagparse is library to build command-line interfaces

  • 0.0.3
  • PyPI
  • Socket score

Maintainers
1

Flagparse

Build Status

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.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc