Giter Club home page Giter Club logo

clap's Introduction

RedCLAP - Command Line Arguments Parser (Redesigned)

CLAP aims at being powerful and advanced command line interface library for the Python 3 language. Having built-in support for modes, optional and obligatory options, options with arguments (with type-checking with arbitrary types) it enables programmers to create rich command line interfaces for Python 3 programs.


Features of CLAP:

  • support for single-level and nested modes (with per-mode and global options),
  • support for grouped short options (ls -lhR),
  • support for long options with or without equal-sign-connected arguments (--log=./file.log and --log ./file.log are both correct),
  • support for option aliases (short/long names),
  • support for typed arguments (str, int, float built-in and other arbitrary types via callbacks),
  • built-in type checking of option arguments,
  • support for multiple arguments for options (e.g. --point 0 0),
  • checking for missing arguments with options which require them,
  • checking for conflicting options (eg. --quiet must not come with option --verbose),
  • support for options that MUST be passed to the program,
  • support for options required by other options (e.g. --key requires --value),
  • support for options wanted by other options (e.g. --which wants --this or --that or both),
  • good set of exceptions with detailed error messages,
  • ability to load interface from JSON descriptions,
  • automatic generation of help screens (for your-tool help command) with per-mode, per-option, and per-operand descriptions, usage examples, and more
  • support for shortcuts for command names (shortest-unique name is sufficient for CLAP to resolve the command, it is not necessary to write full names)

CLAP is not the most easy to use command line arguments parser for Python, but I am quite confident that it is one of the most powerful (if not the most powerful) framework for writing command line interfaces. With excellent support for modes, options, and operands, automatic input verification, and help screen generation you get a big return on your investment.


Manual and examples

See the Issue project which is the flagship software for CLAP and uses all features the library offers.


License

RedCLAP is published under GNU GPL v3 or GNU LGPL v3 (or any later version of one of this licenses).

clap's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

clap's Issues

Install fails: mising clap-api/README.markdown in 0.12.0

Looks like somebody miss the README
installation fails with:

Downloading https://files.pythonhosted.org/packages/c4/57/d4a2f5b6161c371606eeb136dab27af40f66764a488187ebd27bca329f1b/clap-api-0.12.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/data/data/com.termux/files/usr/tmp/pip-install-afo9fht5/clap-api/setup.py", line 17, in <module>
        with open(path.join(here, 'README.markdown'), encoding='utf-8') as f:
      File "/data/data/com.termux/files/usr/lib/python3.7/codecs.py", line 898, in open
        file = builtins.open(filename, mode, buffering)
    FileNotFoundError: [Errno 2] No such file or directory: '/data/data/com.termux/files/usr/tmp/pip-install-afo9fht5/clap-api/README.markdown'

Refactor Makefile for better installation compatibility

Summary

I would like to propose a refactoring of the Makefile in order to improve the installation process and ensure compatibility with Python environments and package managers such as virtual environments and asdf.

Currently, the Makefile assumes the installation path based on the PYTHONVERSION variable, which may not be suitable when using package managers like asdf or when working within a virtual environment. To address this, I suggest using the SITE_PACKAGES_PATH variable, which provides a more reliable installation path across different environments.

Proposed change

Here is the proposed refactored code for the Makefile:

PYTHONVERSION=`python3 -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
SITE_PACKAGES_PATH = `python -c "import site; print(site.getsitepackages()[0])"`

.PHONY: tests tests-python2

version:
	@echo "$(PYTHONVERSION)"

doc:
	echo "" > DOC
	pydoc3 ./clap/* >> DOC

global-install:
	make tests
	make clean
	mkdir $(SITE_PACKAGES_PATH)/clap
	cp -v ./clap/*.py $(SITE_PACKAGES_PATH)/clap

install: ./clap/*.py
	mkdir $(SITE_PACKAGES_PATH)/clap
	cp -v ./clap/*.py $(SITE_PACKAGES_PATH)/clap

clean:
	rm -rf ./clap/__pycache__


test:
	python3 ./tests/clap/tests.py --catch --failfast --verbose 

test-builder:
	python3 ./tests/clap/buildertests.py --catch --failfast --verbose 

test-example-ui-run:
	python3 ./examples/nested.py > /dev/null
	python3 ./examples/nested.py help > /dev/null
	python3 ./examples/nested.py help help > /dev/null
	python3 ./examples/nested.py help help --help > /dev/null

test-example-ui-helper-output:
	@python3 ./examples/nested.py help
	@python3 ./examples/nested.py help help
	@python3 ./examples/nested.py help help --usage

test-cover: test test-builder test-example-ui-run

The main change is the introduction of the SITE_PACKAGES_PATH variable, which is set to the appropriate site packages directory using the site module in Python. This variable is then used in the install command.

This modification will enable users to install the clap package correctly, regardless of their Python environment or package manager by calling the make install command from an active virtualenv.

Let me know if you would like me to contribute this change and submit a pull request, or if you have any alternative thoughts. Thanks!

New tag/release

Hi, I intend to package your software because it's a dependency to another software. I saw you did a commit last year.

Could you make a new tag/release? I will use it to package.

Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.