cli

package
v0.0.0-...-1bfbc23 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ARGS []Flag[any] = []Flag[any]{
	{
		"port",
		"12345",
		"specify the port for '--live-preview' to be served on",
		"live-preview",
	},
}
View Source
var OPTIONS []Flag[bool] = []Flag[bool]{
	{
		"help",
		false,
		"prints the help page, exists",
		"",
	},
	{
		"config",
		false,
		"uses fleck.json as the source for fleck's command line interface",
		"",
	},
	{
		"escape-html",
		false,
		"escapes html elements found in the markdown source in the output html",
		"",
	},
	{
		"watch",
		false,
		"watches for changes in the specified page, recompiles the file on change",
		"",
	},
	{
		"syntax",
		false,
		"enables syntax highlighting for code blocks in the output using prism",
		"",
	},
	{
		"math",
		false,
		"enables latex math rendering in the output using katex",
		"",
	},
	{
		"live-preview",
		false,
		"same as watch, serves the compiled html, reloads tab if change occured",
		"",
	},
	{
		"debug",
		false,
		"enables debug logs",
		"",
	},
	{
		"version",
		false,
		"prints version and build information, exists",
		"",
	},
	{
		"no-prefix",
		false,
		"hide the informational comments generated in the output html",
		"",
	},
	{
		"no-template",
		false,
		"write html output to a file without the default html scaffolding",
		"",
	},
	{
		"silent",
		false,
		"disables info logs, reduces output significantly",
		"",
	},
	{
		"toc",
		false,
		"generates a table of contents at the top of the output file, includes headings 1,2,3",
		"",
	},
	{
		"toc-full",
		false,
		"generates a full toc, includes headings 1,2,3,4,5,6",
		"toc",
	},
	{
		"keep-temp",
		false,
		"keeps fleck from removing temporary files, used for debug purposes",
		"preprocessor-enabled",
	},
	{
		"preprocessor-enabled",
		false,
		"enables the preprocessor to replace macros, decreases performance",
		"",
	},
	{
		"shell-macro-enabled",
		false,
		"enables the dangerous '@shell{command}' macro",
		"preprocessor-enabled",
	},
}

Functions

func PrintLongHelp

func PrintLongHelp()

prints the help with all options available

func PrintShortHelp

func PrintShortHelp()

prints a help page with only the usage

func PrintVersion

func PrintVersion(version, buildAt, buildBy string)

Types

type Arguments

type Arguments struct {
	Flags map[string]*bool
	Args  map[string]*string
	Files []string // files
}
var ARGUMENTS Arguments

func GetConfigFromFile

func GetConfigFromFile(in io.Reader) (Arguments, error)

func ParseCli

func ParseCli() *Arguments

register program options to the flag pkg, parse them, return arguments struct

func (*Arguments) GetArg

func (a *Arguments) GetArg(name string) string

returns the value of an option, if option not found / set returns false, otherwise returns the options value

func (*Arguments) GetFlag

func (a *Arguments) GetFlag(name string) bool

returns the value of an option, if option not found / set returns false, otherwise returns the options value

func (*Arguments) String

func (a *Arguments) String() string

type Flag

type Flag[T any] struct {
	Name        string
	Default     T
	Description string
	Requires    string // other flag this flag requires
}

type FleckConfig

type FleckConfig struct {
	Sources []string // input files
	Flags   []string // fleck cli flags
}

TODO: add support for arguments, such as port

Jump to

Keyboard shortcuts

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