Getting Started
Installation
Install Clantic using pip:
Basic Usage
1. Define Parameters
First, define your command parameters using a Pydantic model:
from pydantic import BaseModel
from clantic.types import Argument, Option
class GreetParams(BaseModel):
name: Argument[str] # required argument
greeting: Option[str] = "Hello" # optional with default
2. Create Command
Create a command by inheriting from BaseCommand:
from clantic import BaseCommand
class GreetCommand(BaseCommand[GreetParams]):
NAME = "greet"
def run(self) -> None:
print(f"{self.params.greeting}, {self.params.name}!")
3. Create CLI Group
Group your commands and create the CLI:
from clantic import Group
cli = Group()
cli.add_command_cls(GreetCommand)
if __name__ == "__main__":
cli()
4. Run the CLI
Your CLI is now ready to use:
Next Steps
- Learn about different Parameter Types
- Explore Command Configuration
- See how to Test Your CLI