Code Monkey home page Code Monkey logo

cookiecutter-click-namespace's Introduction

cookiecutter-click-namespace

cookiecutter-click-namespace is a template for pluginable cli command based on Click.
Commands created with this template can add subcommands using pip.

This repository is a main package template and plugin package template is here.

How to use

This tutorial create two packages flowers and flowers-tulip.
The flowers is also namespace command like aws command or gcloud command. The flowers-tulip package is for tulip subcommand like aws ec2 command or gcloud compute. You can also add other commands such as rose or dandelion by developing a plugin.

Installing a namespace command

# Install cookiecutter
$ python3 -m venv venv
$ . venv/bin/activate
(venv) $ pip install cookiecutter

# Create a main package for namespace command
(venv) $ cookiecutter https://github.com/rhoboro/cookiecutter-click-namespace
namespace [maincommand]: flowers
author [yourname]: rhoboro
author_email [yourname@domain]: [email protected]
(venv) $ ls
flowers venv

# And install
(venv) $ pip install flowers/  # Don't forget the trailing slash
Processing ./flowers
Requirement already satisfied: click in ./venv/lib/python3.7/site-packages (from flowers==1.0.0) (7.0)
Installing collected packages: flowers
  Running setup.py install for flowers ... done
Successfully installed flowers-1.0.0

# The namespace command has been installed
(venv) $ flowers
Usage: flowers [OPTIONS] COMMAND [ARGS]...

  Namespace for extra commands

Options:
  -v, --verbose [NONE|DEBUG|INFO|WARNING|ERROR]
                                  to set log level  [default: NONE]
  -h, --help                      Show this message and exit.

Install extra command

# Create a extra package for subcommand
(venv) $ cookiecutter https://github.com/rhoboro/cookiecutter-click-namespace-plugin
namespace [maincommand]: flowers  # Same as above
plugin [subcommand]: tulip  # Extra command name
author [yourname]: rhoboro
author_email [yourname@domain]: [email protected]
(venv) $ ls
flowers       flowers.tulip venv

# And install
(venv) $ pip install flowers.tulip/  # Don't forget the trailing slash
Processing ./flowers.tulip
Requirement already satisfied: click in ./venv/lib/python3.7/site-packages (from flowers-tulip==1.0.0) (7.0)
Installing collected packages: flowers-tulip
  Running setup.py install for flowers-tulip ... done
Successfully installed flowers-tulip-1.0.0

# Finally, subcommand has been installed
(venv) $ flowers
Usage: flowers [OPTIONS] COMMAND [ARGS]...

  Namespace for extra commands

Options:
  -v, --verbose [NONE|DEBUG|INFO|WARNING|ERROR]
                                  to set log level  [default: NONE]
  -h, --help                      Show this message and exit.

Commands:
  tulip  Command Group  # tulip is here!!

# tulip is a command group
(venv) $ flowers tulip
Usage: flowers tulip [OPTIONS] COMMAND [ARGS]...

  Command Group

Options:
  -h, --help  Show this message and exit.

Commands:
  sample  Sample command
(venv) $ flowers tulip sample
tulip's sample was called

cookiecutter-click-namespace's People

Contributors

rhoboro avatar

Watchers

 avatar  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.