Coder Social home page Coder Social logo

shtab's Introduction

Logo

Tests Coverage conda-forge PyPI

  • What: Automatically generate shell tab completion scripts for Python CLI apps
  • Why: Speed & correctness. Alternatives like argcomplete and pyzshcomplete are slow and have side-effects
  • How: shtab processes an argparse.ArgumentParser object to generate a tab completion script for your shell
  • Outputs tab completion scripts for
    • bash
    • zsh
    • tcsh
  • Supports
  • Supports arguments, options and subparsers
  • Supports choices (e.g. --say={hello,goodbye})
  • Supports file and directory path completion
  • Supports custom path completion (e.g. --file={*.txt})

Choose one of:

  • pip install shtab, or
  • conda install -c conda-forge shtab

See operating system-specific instructions in the docs.

There are two ways of using shtab:

  • CLI Usage: shtab's own CLI interface for external applications
    • may not require any code modifications whatsoever
    • end-users execute shtab your_cli_app.your_parser_object
  • Library Usage: as a library integrated into your CLI application
    • adds a couple of lines to your application
    • argument mode: end-users execute your_cli_app --print-completion {bash,zsh}
    • subparser mode: end-users execute your_cli_app completion {bash,zsh}

See the docs for usage examples.

Not working? Check out frequently asked questions.

  • argcomplete
    • executes the underlying script every time <TAB> is pressed (slow and has side-effects)
    • only provides bash completion
  • pyzshcomplete
    • executes the underlying script every time <TAB> is pressed (slow and has side-effects)
    • only provides zsh completion
  • click
    • different framework completely replacing the builtin argparse
    • solves multiple problems (rather than POSIX-style "do one thing well")

Please do open issues & pull requests! Some ideas:

  • support fish
  • support powershell

See CONTRIBUTING.md for more guidance.

Hits

shtab's People

Contributors

casperdcl avatar simaoafonso-pwt avatar efiop avatar brentyi avatar dtrifiro avatar jimporter avatar skshetry avatar bmorledge-hampton19 avatar amurzeau avatar hajs avatar woodruffw avatar

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.