Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A CLI tool for managing your CLI tools

Project description

COCO

Coco is a tool for collecting commands in an easy and organized way.

Usage of arguments

Installation

Coco is available in PyPi and can be installed via pip:

pip install --user coco-cli

Features

  • Custom prompts :star2:
  • List existing prompts :notebook:
  • Add or remove prompts :cactus:
  • Easy to remember commands like ls for listing or rm for removing :bulb:

Usage

Usage: coco [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  add  Add a prompt
  ls   List all prompts
  new  Generate a default config file
  rm   Remove a prompt
  run  Run a prompt

Generate config files

To generate a new config file and simultaneously add the prompt you can simply use the command

coco new [PATH] [NAME]

Where [PATH] specifies the destination of the config file and [NAME] the name of the prompt that coco saves.

For example coco new ~/.config/coco/maven.json mvn will generate a file named maven.json in ~/.config/coco, which can be executed with coco run mvn.

Note that the name of the config file as well as the file extension do not matter. However since coco expects valid json it is a nice convention to use the .json extension.

Add prompt

If you've already created a valid config file with your desired commands you can add it via

coco add [PATH] [NAME]

Where [PATH] specifies the location of the config file and [NAME] the name of the prompt that coco saves.

See Generate Config File for a more detailed example.

Run a prompt

In order to view an added prompt simply enter

coco run [NAME]

If the prompt requires parameters you can either append them at the end or let coco ask the user for input:

Usage of arguments

And a possible config file entry could look like this

{
    "prompt": "Select command to run:",
    "choices": {
        "Show package details": "pip show {package}",
        ...
    }
}

List available prompts

To list available prompts use

coco ls

Remove a prompt

Removing an existing prompt is as easy as using:

coco rm [NAME]

[Name] of course specifies the name of the prompt that you wish to remove. To list the names of all available prompts use coco ls.

If you wish to also delete the associated config file from your system add the --delete-config flag:

coco rm --delete-config [NAME]

Config Files

An example config file can be viewed here

As you can probably guess the file needs to be valid json, however the file extension does not matter.

If you want to specify arguments for your commands you can do so by wrapping them in curly braces:

{
    "prompt": "Pacman commands:",
    "choices": {
        "install": "sudo pacman -S {package}"
    }
}

TODO

  • [ ] Support for piped operations
  • [ ] Usage of the same argument in multiple places like pip search {package} | grep {package}
  • [ ] Add new command to easily edit the config files

Project details


Download files

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

Files for coco-cli, version 2.3
Filename, size File type Python version Upload date Hashes
Filename, size coco_cli-2.3-py3-none-any.whl (6.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page