config

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LeetCodeCN LeetcodeSite = "https://leetcode.cn"
	LeetCodeUS LeetcodeSite = "https://leetcode.com"
	ZH         Language     = "zh"
	EN         Language     = "en"
)

Variables

View Source
var (
	SkippedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#b8b8b8"))
	PassedStyle  = lipgloss.NewStyle().Foreground(lipgloss.Color("#00b300"))
	ErrorStyle   = lipgloss.NewStyle().Foreground(lipgloss.Color("#ff0000"))
	FailedStyle  = lipgloss.NewStyle().Foreground(lipgloss.Color("#ff6600"))
	StdoutStyle  = lipgloss.NewStyle().Faint(true)
)
View Source
var (
	Debug = os.Getenv("DEBUG") == "1"
)

Functions

func Load

func Load(init bool) error

func SaveState

func SaveState(s State)

Types

type BaseLangConfig

type BaseLangConfig struct {
	OutDir                  string     `` /* 143-byte string literal not displayed */
	FilenameTemplate        string     `` /* 146-byte string literal not displayed */
	SeparateDescriptionFile bool       `` /* 202-byte string literal not displayed */
	Blocks                  []Block    `yaml:"blocks,omitempty" mapstructure:"blocks" comment:"Replace some blocks of the generated code."`
	Modifiers               []Modifier `yaml:"modifiers,omitempty" mapstructure:"modifiers" comment:"Functions that modify the generated code."`
}

type Block added in v0.1.6

type Block struct {
	Name     string `yaml:"name" mapstructure:"name"`
	Template string `yaml:"template" mapstructure:"template"`
}

type CodeConfig

type CodeConfig struct {
	Lang                    string         `` /* 163-byte string literal not displayed */
	FilenameTemplate        string         `` /* 454-byte string literal not displayed */
	SeparateDescriptionFile bool           `` /* 192-byte string literal not displayed */
	Blocks                  []Block        `yaml:"blocks,omitempty" mapstructure:"blocks" comment:"Default block definitions for all languages."`
	Modifiers               []Modifier     `yaml:"modifiers,omitempty" mapstructure:"modifiers" comment:"Default modifiers for all languages."`
	Go                      GoConfig       `yaml:"go" mapstructure:"go"`
	Python                  PythonConfig   `yaml:"python3" mapstructure:"python3"`
	Cpp                     CppConfig      `yaml:"cpp" mapstructure:"cpp"`
	Rust                    RustConfig     `yaml:"rust" mapstructure:"rust"`
	Java                    BaseLangConfig `yaml:"java" mapstructure:"java"`
}

type Config

type Config struct {
	Author   string         `yaml:"author" mapstructure:"author" comment:"Your name"`
	Language Language       `` /* 132-byte string literal not displayed */
	Code     CodeConfig     `yaml:"code" mapstructure:"code"`
	LeetCode LeetCodeConfig `yaml:"leetcode" mapstructure:"leetcode"`
	Contest  ContestConfig  `yaml:"contest" mapstructure:"contest"`
	Editor   Editor         `yaml:"editor" mapstructure:"editor" comment:"Editor settings to open generated files."`
	// contains filtered or unexported fields
}

func Get

func Get() *Config

func (*Config) CacheDir added in v0.2.1

func (c *Config) CacheDir() string

func (*Config) ConfigFile added in v1.4.1

func (c *Config) ConfigFile() string

func (*Config) DepVersionFile added in v1.4.2

func (c *Config) DepVersionFile() string

func (*Config) HomeDir added in v1.4.1

func (c *Config) HomeDir() string

func (*Config) ProjectRoot

func (c *Config) ProjectRoot() string

func (*Config) QuestionCacheFile added in v0.2.1

func (c *Config) QuestionCacheFile(ext string) string

func (*Config) StateFile

func (c *Config) StateFile() string

func (*Config) TempDir added in v1.3.1

func (c *Config) TempDir() string

func (*Config) Write

func (c *Config) Write(w io.Writer, withComments bool) error

type ContestConfig

type ContestConfig struct {
	OutDir           string `yaml:"out_dir" mapstructure:"out_dir" comment:"Base directory to put generated contest questions."`
	FilenameTemplate string `yaml:"filename_template" mapstructure:"filename_template" comment:"Template to generate filename of the question."`
	OpenInBrowser    bool   `yaml:"open_in_browser" mapstructure:"open_in_browser" comment:"Open the contest page in browser after generating."`
}

type CppConfig added in v1.3.1

type CppConfig struct {
	BaseLangConfig `yaml:",inline" mapstructure:",squash"`
	CXX            string `yaml:"cxx" mapstructure:"cxx" comment:"C++ compiler"`
	CXXFLAGS       string `` /* 126-byte string literal not displayed */
}

type Credentials

type Credentials struct {
	From     string   `yaml:"from" mapstructure:"from" comment:"How to provide credentials: browser, cookies, password or none."`
	Browsers []string `` /* 186-byte string literal not displayed */
}

type Editor

type Editor struct {
	Use     string `` /* 165-byte string literal not displayed */
	Command string `yaml:"command" mapstructure:"command" comment:"Custom command to open files."`
	Args    string `` /* 335-byte string literal not displayed */
}

type GoConfig

type GoConfig struct {
	BaseLangConfig `yaml:",inline" mapstructure:",squash"`
}

type Language

type Language string

type LastQuestion

type LastQuestion struct {
	FrontendID string `json:"frontend_id"`
	Slug       string `json:"slug"`
	Gen        string `json:"gen"`
}

type LeetCodeConfig

type LeetCodeConfig struct {
	Site        LeetcodeSite `yaml:"site" mapstructure:"site" comment:"LeetCode site, https://leetcode.com or https://leetcode.cn"`
	Credentials Credentials  `yaml:"credentials" mapstructure:"credentials" comment:"Credentials to access LeetCode."`
}

type LeetcodeSite

type LeetcodeSite string

type Modifier added in v0.1.6

type Modifier struct {
	Name   string `yaml:"name" mapstructure:"name"`
	Script string `yaml:"script,omitempty" mapstructure:"script"`
}

type PythonConfig added in v1.3.1

type PythonConfig struct {
	BaseLangConfig `yaml:",inline" mapstructure:",squash"`
	Executable     string `yaml:"executable" mapstructure:"executable" comment:"Path to the python executable that creates the venv."`
}

type RustConfig added in v1.3.1

type RustConfig struct {
	BaseLangConfig `yaml:",inline" mapstructure:",squash"`
}

type State

type State struct {
	LastQuestion LastQuestion `json:"last_question"`
	LastContest  string       `json:"last_contest"`
}

func LoadState

func LoadState() State

type States

type States map[string]State

Jump to

Keyboard shortcuts

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