okapicli

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 12 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// SIGINT is the interrupt signal
	SIGINT = syscall.SIGINT
	// SIGTERM is the termination signal
	SIGTERM = syscall.SIGTERM
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

type CLI struct {
	// contains filtered or unexported fields
}

func New

func New(o *okapi.Okapi, name ...string) *CLI

New creates a new CLI manager for the Okapi You can optionally provide a custom application name

func (*CLI) Bool

func (c *CLI) Bool(name, shorthand string, defaultValue bool, usage string) *CLI

Bool adds a boolean flag with optional shorthand

func (*CLI) Float

func (c *CLI) Float(name, shorthand string, defaultValue float64, usage string) *CLI

Float adds a float64 flag with optional shorthand

func (*CLI) Get

func (c *CLI) Get(name string) interface{}

Get retrieves a flag value by name

func (*CLI) GetBool

func (c *CLI) GetBool(name string) bool

GetBool retrieves a bool flag value

func (*CLI) GetFloat

func (c *CLI) GetFloat(name string) float64

GetFloat retrieves a float64 flag value

func (*CLI) GetInt

func (c *CLI) GetInt(name string) int

GetInt retrieves an int flag value

func (*CLI) GetString

func (c *CLI) GetString(name string) string

GetString retrieves a string flag value

func (*CLI) Int

func (c *CLI) Int(name, shorthand string, defaultValue int, usage string) *CLI

Int adds an integer flag with optional shorthand

func (*CLI) LoadConfig

func (c *CLI) LoadConfig(path string, v interface{}) error

LoadConfig loads configuration from a file (JSON or YAML) into a struct

func (*CLI) ParseFlags

func (c *CLI) ParseFlags() error

ParseFlags parses the command line flags

func (*CLI) Run

func (c *CLI) Run() error

Run starts Okapi using default options and waits for shutdown signals. It handles graceful shutdown automatically.

It is a shortcut for RunServer(nil)

func (*CLI) RunServer

func (c *CLI) RunServer(opts ...*RunOptions) error

RunServer starts Okapi and waits for shutdown signals. It handles graceful shutdown automatically

func (*CLI) String

func (c *CLI) String(name, shorthand, defaultValue, usage string) *CLI

String adds a string flag with optional shorthand

type RunOptions

type RunOptions struct {
	// ShutdownTimeout is the maximum time to wait for graceful shutdown
	ShutdownTimeout time.Duration

	// Signals are the OS signals to listen for (defaults to SIGINT, SIGTERM)
	Signals []os.Signal

	// OnStart is called right before the server starts
	OnStart func()

	// OnStarted is called after the server starts successfully
	OnStarted func()

	// OnShutdown is called before shutdown begins
	OnShutdown func()
}

RunOptions configures the Run behavior

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL