Giter VIP home page Giter VIP logo

nci-python-commands's Introduction

nci-python-commands

Python commands is a light-weight, django-admin inspired, CLI Command tool.

Usage

pip install nci-python-commands
manage

List available commands

manage

Run Commands

manage my-command-name

Create Command

  1. Create File

You can create a blank command by typing the following:

manage create_command
  1. Example Code

In print_my_number.py:

from commandable import Command


class PrintMyNumber(Command):
    description = "A description of your command"

    def __init__(self, args=None):
        self.register_argument(
            "-v",
            nargs='?',
            const=True,
            type=bool,
            description="Verbose output"
        )

        self.register_argument(
            "--mynumber",
            description="What is your number?",
            default=2,
            type=int
        )

        super().__init__(args)

    def command(self, **kwargs):
        # Place your command code here
        if self.get("v"):
            print("Verbose mode is on")

        print("Your lucky number is: {}".format(self.get("mynumber"))) #Your lucky number is: 2

Hide Commands

class PrintMyNumber(Command):
    description = "A description of your command"

    hidden = True
...

Adding existing commands to you configuration

In the section Commands add the module names that need to be scanned for commands and add a readable name as value.

Commands:
  modulename: "module.path"
  downloaddata: "download.data"
  importers: "import_data"

nci-python-commands's People

Contributors

cedriclevarlet avatar jobtg avatar

Watchers

 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.