config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config validates flag values and command line arguments and converts them to read-only type-safe values for mdrip.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Usage

func Usage()

Usage prints a usage message to stdErr.

Types

type Config

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

Config holds configuration for an instance of mdrip.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig is a config for tests.

func GetConfig

func GetConfig() (*Config, error)

GetConfig parses configuration from command line args.

func (*Config) BlockTimeOut

func (c *Config) BlockTimeOut() time.Duration

BlockTimeOut is the duration to give a block to run before considering it dead.

func (*Config) DataSet

func (c *Config) DataSet() *base.DataSet

DataSet holds the source of data parsed from the mdrip command line.

func (*Config) HostAndPort

func (c *Config) HostAndPort() string

HostAndPort for the server when in ModeDemo.

func (*Config) IgnoreTestFailure

func (c *Config) IgnoreTestFailure() bool

IgnoreTestFailure means don't exit with error if a test fails in ModeTest.

func (*Config) Label

func (c *Config) Label() base.Label

Label to use when extracting code blocks for testing or printing.

func (*Config) Mode

func (c *Config) Mode() ModeType

Mode returns the mode of the mdrip instance.

func (*Config) Preambled

func (c *Config) Preambled() int

Preambled is a count of blocks to run in the current shell before staring a subshell, to impact the env of the current shell.

type ModeType

type ModeType int

ModeType distinguishes the primary modes of execution in mdrip main.go. These could be separate programs, but don't want to require multiple downloads.

const (

	// ModePrint - extract code to stdout.
	ModePrint ModeType
	// ModeTest - run extracted code in a subshell, reporting errors.
	ModeTest
	// ModeDemo - render markdown in a webserver.
	ModeDemo
	// ModeTmux - run a tiny server that connects tmux to an mdrip in ModeDemo.
	ModeTmux
)

Jump to

Keyboard shortcuts

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