Coder Social home page Coder Social logo

contains-io / rcli Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 5.0 189 KB

Rapidly create full-featured command line interfaces with help, subcommand dispatch, and validation.

License: MIT License

Python 100.00%
command-line autocomplete python python2 python3 zsh bash docopt pep484 types

rcli's People

Contributors

briancappello avatar dangle avatar zancas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rcli's Issues

Add missing docstrings.

Much of the initial code is missing docstrings. These should be fully completed before release.

Test all major functionality.

Rapcom needs tests to cover all expected functionality. This is not intended to be exhaustive, but should at least handle the happy paths.

Unable to overwrite the primary command.

Users should be able to add functionality to the primary command when no subcommand is specified. e.g.

def hello():
    """usage: hello"""
    print('Hello!')

If no subcommands are detected, the help message should not mention anything about subcommands, or allow the usage of subcommands; otherwise, subcommands should work as expected.

Add i18n and l10n support.

Usage strings should support internationalization and localization support.

These can be keyed on the full name of the object to which the docstring is attached and parsed using the docopt language.

Remove validation assumptions.

Remove checks for .validate() and .schema.validate() because these will be entirely replaced by type hinting in 0.2.0+.

Simplify adding primary command functionality.

It should be possible to create a primary command without recreating all of the help logic or reproducing the entirely of the original help message.

Ideally, a single line usage string would be appended to the existing default help string.

If a subcommand is unknown, the primary command function should be called with the value of the subcommand.

Autodetect commands from docstrings.

Add a setup keyword that will scan all python packages for modules, classes, and functions that have docopt compatible docstrings and create entry points from those docstrings.

Normalization of parameters doesn't handle duplicates.

If an option is described as (--option <opt> | <opt>) the value that is None can overwrite the value passed in by the user.

This should be check the values. If one is None, and the other is not, then use the one that is not. If neither is none, normalize to a list of values.

Log on BaseException.

fabric raises SystemExit which inherits from BaseException rather than Exception. rcli should capture this and print the log.

Add method to retrieve log stream.

It should be easy for clients using this project to access the log data. This can be handled by adding a wrapper function in log.py that will return _LOGFILE_STREAM.getvalue()

Add logging support.

Add a --log-level attribute to the global command (that can exist anywhere in the command line arguments) that will set logging.

Enhance normalization.

Normalization is very primitive. It should be changed to remove all invalid python characters, left strip all hyphens, and handle other conversion use cases.

Dump logs on exceptions.

When an error occurs, instead of just returning the exception, return the exception message plus a message telling the user to look at a log file.

The log file must be generated at the time the exception is caught.

Unicode decode error in py27

After an exception has occurred, it's possible for appending the "Please see the log" message to cause a decode error if the string has an unexpected encoding.

Left justify status messages.

In some cases, the TQDM progress bar is not being completely overwritten before the cursor is moved to another line. Left justifying the status description messages will force the line to be cleared.

Correct bad indentation in usage strings.

If a consumer writes a function such as:

def hello(uppercase):
    """Usage: say hello --uppercase

    Options:
      --uppercase  Shout it!
    """

the dedenting will fail because the first line doesn't match the indentation level of the rest of the usage string.

Fire-style non-installed CLI creation.

Google Fire allows command line interfaces to be created by passing a class to a Fire object and calling it. rcli should allow the same functionality but with rcli style documentation and typing.

Remove Python 2 support.

rcli was originally designed and written with Python 2 as a primary consumer. Python 2 has been deprecated since this year.

Consider upgrading to Python 3.5 or Python 3.6 as minimum versions of Python.

Add missing tests.

Add tests for all known use cases.

  • Simple example
  • Explicit example
  • Validation example
  • Module example
  • Class example
  • Schema example

This should also add coveralls support and configure .travis.yml to run the tests as well as linting.

Normalization shouldn't shadow built-in functions.

Currently, normalization checks to verify that a normalized value is not a keyword, but it should also check to see if it is in the built-ins to keep from shadowing those values.

if keyword.iskeyword(nk): should become if keyword.iskeyword(nk) or nk in six.moves.builtins:

Add documentation.

  • Update the README to contain instructions and examples.
  • Convert the markdown file to reST.

Add automatic usage wrapping.

Usage strings should wrap automatically to the size of the terminal being used. Currently, this is limited by the output of docopt.

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.