Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.0.0-...-a714156 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package cli organizes and implements a command line program.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(args []string) int

Run creates an App, performs the App's tasks, and returns an exit value.

Types

type App

type App struct {
	Trap          chan os.Signal
	Port          string
	Dir           string
	ExitValue     int
	HelpWanted    bool
	VersionWanted bool
}

App stores information about the application's state.

func (*App) CloseTrap

func (app *App) CloseTrap()

CloseTrap closes the os.Signal channel.

func (*App) NewLogger

func (app *App) NewLogger(w io.Writer) *slog.Logger

NewLogger returns a configured slog logger or nil.

func (*App) NewServer

func (app *App) NewServer(logger *slog.Logger) *http.Server

NewServer returns an http.Server configured for use by miniserve.

func (*App) NoOp

func (app *App) NoOp() bool

NoOp determines whether an App should bail out.

func (*App) ParseFlags

func (app *App) ParseFlags(args []string)

ParseFlags handles flags and options in my finicky way.

func (*App) StartAndShutdown

func (app *App) StartAndShutdown(server *http.Server, logger *slog.Logger)

StartAndShutdown starts and (gracefully) shuts down an http.Server.

func (*App) TrapSignals

func (app *App) TrapSignals(signals ...os.Signal)

TrapSignals sets app.Trap to watch for a variable number of signals.

type WrappedDir

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

WrappedDir wraps http.Dir so that we can modify http.Dir's Open method.

func (WrappedDir) Open

func (wd WrappedDir) Open(name string) (http.File, error)

Open modifies http.Dir's Open method in order to handle URLs without ".html".

Jump to

Keyboard shortcuts

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