Skip to main content
Add custom commands to the Osmedeus CLI.

Overview

CLI commands use Cobra and are defined in pkg/cli/. Each command file typically contains one main command with optional subcommands.

Command Structure

Steps to Add a Command

1. Create Command File

Create pkg/cli/mycommand.go:

2. Use Terminal Helpers

The internal/terminal package provides output formatting:

3. Access Configuration

4. Handle Errors

5. Add Command Help

Example: Export Command

Flag Types

Best Practices

  1. Use subcommands for related actions
  2. Provide aliases for common commands
  3. Write helpful examples in Long description
  4. Validate input early before processing
  5. Use terminal helpers for consistent output
  6. Handle interrupts with context

Next Steps