config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileName is the name of the configuration file
	FileName = ".config.yml"
)

Variables

View Source
var AppDir = os.Getenv(envAppDir)

AppDir is the directory in which the application stores its files

Functions

func DescribeEnvVars

func DescribeEnvVars() string

DescribeEnvVars returns a description string for environment variables used to configure the application

func EnsureAppDir

func EnsureAppDir() error

EnsureAppDir validates that the application directory exists or is created

func ValidateOpts

func ValidateOpts(opts Opts) error

ValidateOpts returns an error if the specified options are misconfigured

Types

type ArchiveOpts

type ArchiveOpts struct {
	AfterDays                int    `yaml:"afterDays" env:"TEXTNOTE_ARCHIVE_AFTER_DAYS" env-description:"number of days after which to archive a file"`
	FilePrefix               string `yaml:"filePrefix" env:"TEXTNOTE_ARCHIVE_FILE_PREFIX" env-description:"prefix attached to the file name of all archive files"`
	HeaderPrefix             string `yaml:"headerPrefix" env:"TEXTNOTE_ARCHIVE_HEADER_PREFIX" env-description:"override header prefix for archive files"`
	HeaderSuffix             string `yaml:"headerSuffix" env:"TEXTNOTE_ARCHIVE_HEADER_SUFFIX" env-description:"override header suffix for archive files"`
	SectionContentPrefix     string `` /* 132-byte string literal not displayed */
	SectionContentSuffix     string `` /* 132-byte string literal not displayed */
	SectionContentTimeFormat string `` /* 140-byte string literal not displayed */
	MonthTimeFormat          string `` /* 128-byte string literal not displayed */
}

ArchiveOpts are options for configuring note archives

type CliOpts

type CliOpts struct {
	TimeFormat string `yaml:"timeFormat" env:"TEXTNOTE_CLI_TIME_FORMAT" env-description:"formatting string for timestamp CLI flags"`
}

CliOpts are options for configuring the CLI

type FileOpts

type FileOpts struct {
	Ext        string `yaml:"ext" env:"TEXTNOTE_FILE_EXT" env-description:"extension for all files written"`
	TimeFormat string `yaml:"timeFormat" env:"TEXTNOTE_FILE_TIME_FORMAT" env-description:"formatting string to form file names from timestamps"`
	CursorLine int    `yaml:"cursorLine" env:"TEXTNOTE_FILE_CURSOR_LINE" env-description:"line to place cursor when opening"`
}

FileOpts are options for configuring file outputs

type HeaderOpts

type HeaderOpts struct {
	Prefix           string `yaml:"prefix" env:"TEXTNOTE_HEADER_PREFIX" env-description:"prefix to attach to header"`
	Suffix           string `yaml:"suffix" env:"TEXTNOTE_HEADER_SUFFIX" env-description:"suffix to attach to header"`
	TrailingNewlines int    `` /* 127-byte string literal not displayed */
	TimeFormat       string `yaml:"timeFormat" env:"TEXTNOTE_HEADER_TIME_FORMAT" env-description:"formatting string to form headers from timestamps"`
}

HeaderOpts are options for configuring the header of a note

type Opts

type Opts struct {
	Header  HeaderOpts  `yaml:"header"`
	Section SectionOpts `yaml:"section"`
	File    FileOpts    `yaml:"file"`
	Archive ArchiveOpts `yaml:"archive"`
	Cli     CliOpts     `yaml:"cli"`
}

Opts are options that configure the application

func LoadOrCreate

func LoadOrCreate() (Opts, error)

LoadOrCreate loads a config file or creates it using defaults

type SectionOpts

type SectionOpts struct {
	Prefix           string   `yaml:"prefix" env:"TEXTNOTE_SECTION_PREFIX" env-description:"prefix to attach to section names"`
	Suffix           string   `yaml:"suffix" env:"TEXTNOTE_SECTION_SUFFIX" env-description:"suffix to attach to section names"`
	TrailingNewlines int      `` /* 134-byte string literal not displayed */
	Names            []string `yaml:"names" env:"TEXTNOTE_SECTION_NAMES" env-description:"section names"`
}

SectionOpts are options for configuring sections of a note

Jump to

Keyboard shortcuts

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