Skip to main content

Shell completions made easy.

Project description

This is not being maintained.

Please check: https://github.com/pwwang/pyparam for shell completions.

completions

pypi tag travis codacy quality pyver

Shell completions for your program made easy.

Installation

pip install completions
# install lastest version using poetry
git clone https://github.com/pwwang/completions
cd completions
poetry install

Usage

Defining your completions

You may define your completions, basically commands and options, by following schema (showed in yaml, but can be any format supported by python-simpleconf: example.yaml

program:
    # your program, or path to your program
    name: completions-example
    desc: Shell completions for your program made easy.
    # whether global options should be inherited by commands
    inherit: true
    # options or global options if you have commands
    options:
        -s: The shell, one of bash, fish, zsh and auto.
        --shell: The shell, one of bash, fish, zsh and auto.
        -a: Automatically write completions to destination file.
        --auto: Automatically write completions to destination file.
commands:
    # No other options for command, give the description
    self: Generate completions for myself.
    generate:
        desc: Generate completions from configuration files.
        options:
            -c: The configuration file to load.
            --config: The configuration file to load.

How it looks like in fish: command option

Generating completion scripts

  • Bash
    > completions generate --shell bash \
        --config example.yaml > ~/bash_completion.d/completions.bash-completion
    
    You may need to source it in your .bashrc and restart your shell for the changes to take effect.
  • Fish
    > completions generate --shell fish \
        --config example.yaml > ~/.config/fish/completions/completions.fish
    
    You may need to restart your shell for the changes to take effect.
  • Zsh
    > completions generate --shell zsh \
        --config example.yaml > ~/.zsh-completions/_completions
    
    Make sure fpath+=~/.zsh-completions is put before compinit in you .zshrc

Saving completions scripts automatically

  • Bash

    > completions generate --shell bash --config example.yaml --auto
    
  • Fish

    > completions generate --shell fish --config example.yaml --auto
    
  • Zsh

    > completions generate --shell zsh --config example.yaml --auto
    

Python API

from completions import Completions
completions = Completions(
    # if not given, will be read from sys.argv[0]
    name    = 'completions',
    # Add global options to commands
    inherit = True,
    desc    = 'Shell completions for your program made easy.')
completions.addOption(
    ['-s', '--shell'],
    'The shell, one of bash, fish, zsh and auto.')
completions.addOption(
    ['-a', '--auto'],
    'Automatically write completions to destination file.')
completions.addCommand(
    'self', 'Generate completions for myself.')
completions.addCommand(
    'generate', 'Generate completions from configuration files.')
completions.command('generate').addOption(
    ['-c', '--config'], 'The configuration file to load.')
completions.generate(shell = 'fish', auto = False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

completions-resurrection-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

completions_resurrection-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file completions-resurrection-0.1.0.tar.gz.

File metadata

  • Download URL: completions-resurrection-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for completions-resurrection-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7eed332350aef3e3bdf7d6854bf880b12489689b9488757984e9689147aeff25
MD5 a76b5ea9e3483c9a735c95c625baa396
BLAKE2b-256 cf8d4a6007f3b06c07d537cb3257e67f3874e9879c87baf5909dd477df1efd13

See more details on using hashes here.

File details

Details for the file completions_resurrection-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: completions_resurrection-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for completions_resurrection-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7d04475b145ac5d5c867e7feca0a4aedad45066607d5f0e482a24df91bdd680
MD5 437ccf33c8e6372911c5bd63763675b8
BLAKE2b-256 e91257b2c820a043b9b8bc005a66ee2c70c1b7ff1db86eed214e65465791384e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page