config

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIfNotExists added in v1.1.1

func CreateIfNotExists() error

CreateIfNotExists writes defaults to the configuration file if it does not already exist

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 GetConfigFilePath added in v1.1.1

func GetConfigFilePath() string

GetConfigFilePath constructs the full path to the configuration file

func InitApp added in v1.2.0

func InitApp() error

InitApp initializes the application by ensuring the necessary directories and files exist

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 {
	AppDir                  string      `yaml:"-"` // AppDir is always read from the environment and is not written to file
	Header                  HeaderOpts  `yaml:"header"`
	Section                 SectionOpts `yaml:"section"`
	File                    FileOpts    `yaml:"file"`
	Archive                 ArchiveOpts `yaml:"archive"`
	Cli                     CliOpts     `yaml:"cli"`
	TemplateFileCountThresh int         `` /* 136-byte string literal not displayed */
}

Opts are options that configure the application

func Load added in v1.1.1

func Load() (Opts, error)

Load loads the configuration from file and/or evironment

type OptsBackCompat added in v1.3.2

type OptsBackCompat struct {
	// TemplateFileCountThresh holds the value of the field "templateFileCountTresh" (note the typo) in a yaml configuration file
	TemplateFileCountThresh int `yaml:"templateFileCountTresh"`
}

OptsBackCompat are options maintained for backwards compatibility that will be honored in the absence (zero-value) of their replacements as handled in loadBackCompat()

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