Skip to content

Add new command#

  1. Create a file with name your_command.py in scli/commands/ directory.

  2. Paste below code, your class name should be Command.

    # scli/commands/your_command.py
    
    from scli.commands.base import BaseCommand
    
    
    class Command(BaseCommand):
        name = "your_command"
        description = "A simple description"
        help = """
        A useful help message
        """
    
        def handle(self):
            self.line("It works!")
    

  3. Add your command to INSTALLED_COMMANDS in scli/settings.py.

    INSTALLED_COMMANDS = [
        ... # other commands
        "your_command"
    ]
    

  4. Now test it!

    python -m scli your_command
    

  5. Your should see below output.

    It works!
    

Back to top