flags

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: GPL-3.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package flags provides the command line interface for the Defacto2 server application. With the configuration of the application done using the environment variables, the use of commands should be kept to a minimum.

Index

Constants

View Source
const (
	Title      = "Defacto2 web application"           // Title of this program.
	Domain     = "defacto2.net"                       // Domain of the website.
	Repository = "https://github.com/Defacto2/server" // Repository is the GitHub URL for this project.
	Program    = "defacto2-server"                    // Program is the command line name of this program.
	Author     = "Ben Garrett"                        // Author is the primary programmer of this program.
	Email      = "contact@defacto2.net"               // Email contact for public display.
	RecentYear = 2026                                 // Most recent year of compilation for this program.

)

Variables

View Source
var (
	ErrNoConfig = errors.New("cannot run command as config is nil")
	ErrPrinter  = errors.New("routes printer is not configured")
)

Functions

func Address

func Address(w io.Writer, c *config.Config) *cli.Command

Address command lists the server addresses.

func App

func App(w io.Writer, ver string, c *config.Config, routes ...RoutePrinter) *cli.App

App returns the command line interface for this program. It uses the github.com/urfave.cli/v2 package.

func Arch

func Arch() string

Arch returns the program CPU architecture.

func Check added in v1.14.0

func Check(w io.Writer, c *config.Config) *cli.Command

Check command checks the server configuration.

func Config

func Config(w io.Writer, c *config.Config) *cli.Command

Config command lists the server configuration.

func Copyright() string

Copyright returns a "©" copyright symbol, the respective years and author of this program.

The most recent copyright year is generated from the last commit date.

func Fix

func Fix(w io.Writer, c *config.Config) *cli.Command

Fix command fixes the database and assets.

func Index added in v1.16.1

func Index(w io.Writer, c *config.Config) *cli.Command

Index command rebuilds the PostgreSQL database indexes.

func OS

func OS() string

OS returns the host operating system.

func Routes added in v1.16.1

func Routes(w io.Writer, fn RoutePrinter) *cli.Command

Routes command lists the registered web server routes.

func TempDir added in v1.14.0

func TempDir(w io.Writer, c *config.Config) *cli.Command

TempDir command removes all temporary directories created by this app.

func Version

func Version(s string) string

Version returns a formatted version string for this program including the VersionCommit, OS, CPU Arch, and Go runtime version.

func VersionCommit added in v1.14.0

func VersionCommit(ver string) string

VersionCommit returns a formatted release or git commit version for the repository.

func VersionRelease added in v1.14.0

func VersionRelease(version string) string

VersionRelease returns a formatted release version. The version string is generated by GoReleaser.

Types

type ExitCode

type ExitCode int // ExitCode is the exit code for this program.
const (
	Continue   ExitCode = iota - 1 // Continue is a special case to indicate the program should not exit.
	ExitOK                         // ExitOK is the exit code for a successful run.
	GenericErr                     // GenericError represents a generic error.
	UsageErr                       // UsageError is used for incorrect arguments or usage.
)

func Run

func Run(w io.Writer, ver string, c *config.Config, routes ...RoutePrinter) (ExitCode, error)

Run parses optional command line arguments for this program.

type RoutePrinter added in v1.16.1

type RoutePrinter func(w io.Writer, method string) error

RoutePrinter prints registered HTTP routes to w, optionally filtered by HTTP method.

Jump to

Keyboard shortcuts

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