climain

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Overview

Package climain implements a command's main function.

You should invoke the Run function from the main function of your program.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cmd cliutils.Command, exitfn ExitFunc, argv ...string)

Run runs the main function for the given command with the given ExitFunc and arguments.

The `cmd` argument represents the command to run. We will specifically invoke the Main method of the cliutils.Command and exit (through `exitfn`) with 1 on error.

The `exitfn` argument is the function to call when exiting the program, which is mockable so to more easily write unit tests.

The `argv` arguments contain the command line arguments for the command.

This function will automatically install a signal handler for syscall.SIGINT that will cancel the contect passed to cliutils.Commnd when receiving a signal.

Types

type ExitFunc

type ExitFunc func(code int)

ExitFunc is the type of the os.Exit func.

Jump to

Keyboard shortcuts

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