npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oclif-plugin-completion

v0.6.0

Published

oclif plugin for generating shell completions

Downloads

23,682

Readme

oclif Plugin Version License

oclif Plugin: completion

oclif plugin for generating shell completions

Completion Features

Consider the following dummy CLI:

Usage: dummy <COMMAND> [OPTION...]

Commands:

  open   <ro|rw>      open a dummy (as read-only or read-write)
  save                save a dummy
  search              search a dummy

Options (open):

  -i, --id            dummy id
  -f, --file          path to dummy file
  -d, --dir           path to dummy directory (default: ./dummies)
  -v, --verbose       boolean flag

Options (save):

  -n, --name          dummy name
  -a, --age           dummy age
  -t, --tag           dummy tag, can be multiple (a/b/c/d)
  -f, --file          path to dummy file
  -d, --dir           path to dummy directory (default: ./dummies)
  -o, --overwrite     boolean flag
  -v, --verbose       boolean flag

Options (search):

  -n, --name          dummy name
  -a, --age           dummy age
  -t, --tag           dummy tag, can be multiple (a/b/c/d)
  -v, --verbose       boolean flag

Running on the current directory with tree:

|- dir-one/
|  |- 042.dummy-with-id-042.json
|- dir-two/
|- dummies/
|  |- 109.dummy-with-id-109.json
|  |- 110.dummy-with-id-110.json
|  |- 111.dummy-with-id-111.json
|- file-one.txt
|- file-two.txt

Features Description

File Path completion:

Completion will suggest the files on disk matching glob pattern.

Directory Path completion:

Completion will suggest the directories on disk matching glob pattern.

Dynamic Runtime completion:

Completion will generate the suggestion based on state of runtime environment and/or configuration.

Features Examples

| Feature | Input | Output | | -------------------------- | ------------------------------------ | ---------------------------- | | File Path completion | dummy open --file=./dir/one/<TAB> | 042.dummy-with-id-042.json | | Directory Path completion | dummy open --dir ./di<TAB> | dir-one dir-two | | Dynamic Runtime completion | dummy open --id <TAB> | 109 110 111 | | Dynamic Runtime completion | dummy open -d ./dir-one --id <TAB> | 042 |

Feature Support Matrix

| :+1: | :-1: | :grey_exclamation: | :bug: | :heavy_check_mark: | :heavy_minus_sign: | :x: | | --------- | ----------- | ------------------ | ----- | ------------------ | --------------------- | --------------- | | Supported | Unsupported | Unknown | Bug | Implemented | Partially Implemented | Not Implemented |

| oclif | Feature | Example | Bash | Zsh | Fish | | ---------- | ---------------------------- | ---------------------------------- | ----------------------- | ----------------------- | ----------------------- | | :+1: | Positional argument | ro | :grey_exclamation: :x: | :+1: :heavy_check_mark: | :grey_exclamation: :x: | | :+1: | Basic Long | --name john --age 42 --overwrite | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | | :+1: | Alternate Long | --name=john --age=42 | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | | :+1: | Basic Short | -n john -a 42 -o | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | | :+1: | Alternative Short | -njohn -a42 | :+1: :x: | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | | :+1: | Stacking Short | -ov | :grey_exclamation: :x: | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | | :+1: | Stacking Short with argument | -ova 42 | :grey_exclamation: :x: | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | | :+1: | Options / Enum | --tag a | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | :+1: :heavy_check_mark: | | :+1: :bug: | Multiple | -t c --tag d | :+1: :heavy_minus_sign: | :+1: :heavy_minus_sign: | :+1: :heavy_minus_sign: | | :-1: | File Path completion | --file ... | :+1: :heavy_minus_sign: | :+1: :x: | :+1: :heavy_minus_sign: | | :-1: | Directory Path completion | --dir ... | :+1: :heavy_minus_sign: | :+1: :x: | :+1: :heavy_minus_sign: | | :-1: | Dynamic Runtime completion | --dir ./dummies --id 111 | :+1: :x: | :+1: :x: | :+1: :x: |

Supported Shells

Bash

Reference: Bash Completion

You need to have bash-completion package installed on your system.

Bash Usage

You can enable completion for Bash using various methods. A few of them are mentioned below:

vanilla (.bashrc):

Add the following line in your .bashrc file:

eval "$(dummy completion:generate --shell bash);"

vanilla (completions directory):

Run the following command:

dummy completion:generate --shell bash | tee ~/.local/share/bash-completion/completions/dummy

Depending on you system, the completion script can also be put into one of these directories:

  • ${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions (linux/macos)
  • /usr/local/share/bash-completion/completions (macos)
  • /usr/share/bash-completion/completions (linux)

Zsh

Reference: Zsh Completion System

Zsh Usage

You can enable completion for Zsh using various methods. A few of them are mentioned below:

vanilla (.zshrc):

Add the following line in your .zshrc file:

eval "$(dummy completion:generate --shell zsh); compdef _dummy dummy;"

vanilla (site-functions directory):

Run the following command:

dummy completion:generate --shell zsh | tee "$(echo ${FPATH} | tr ':' '\n' | grep site-functions | head -n1)/_dummy"

The completion script can also be put into one of the directories present in $FPATH variable:

echo $FPATH

zinit:

Run the following commands:

dummy completion:generate --shell zsh > ~/.local/share/zsh/completions/_dummy
zinit creinstall ~/.local/share/zsh/completions

Fish

Reference: Fish Completion

Fish Usage

Reference: Where to put completions

You can enable completion for Fish using various methods. A few of them are mentioned below:

vanilla (completions directory):

Run the following command:

dummy completion:generate --shell fish | tee ~/.config/fish/completions/dummy.fish

Commands

dummy completion

Generate shell completion script

USAGE
  $ dummy completion

OPTIONS
  -s, --shell=bash|fish|zsh  (required) Name of shell

DESCRIPTION
  Run this command to see instructions for your shell.

EXAMPLE
  $ dummy completion --shell zsh

See code: src/commands/completion/index.ts

dummy completion:generate

Generates completion script

USAGE
  $ dummy completion:generate

OPTIONS
  -s, --shell=bash|fish|zsh  (required) Name of shell

DESCRIPTION
  Run the "completion" command to see instructions about how to use the script generated by this command.

EXAMPLE
  $ dummy completion:generate --shell zsh

See code: src/commands/completion/generate/index.ts

dummy completion:generate:alias ALIAS

Generates completion script for alias

USAGE
  $ dummy completion:generate:alias ALIAS

ARGUMENTS
  ALIAS  name of the alias

OPTIONS
  -s, --shell=bash|fish  (required) Name of shell

DESCRIPTION
  This needs the completion script for the main command to be present.

  Check the "completion:generate" command.

See code: src/commands/completion/generate/alias.ts