config

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdName = "leetgo"

	CodeBeginMark = "Leetgo Code Begin"
	CodeEndMark   = "Leetgo Code End"
)
View Source
const (
	LeetCodeCN LeetcodeSite = "https://leetcode.cn"
	LeetCodeUS LeetcodeSite = "https://leetcode.com"
	ZH         Language     = "zh"
	EN         Language     = "en"
)

Variables

View Source
var (
	Debug = os.Getenv("DEBUG") != ""
)

Functions

func Decrypt

func Decrypt(in string) (string, error)

func Encrypt

func Encrypt(in string) (string, error)

func Set

func Set(c Config)

func Verify

func Verify(c *Config) error

Types

type BaseLangConfig

type BaseLangConfig struct {
	OutDir string `yaml:"out_dir" mapstructure:"out_dir"`
}

type Config

type Config struct {
	Author     string         `yaml:"author" mapstructure:"author" comment:"Your name"`
	Gen        string         `` /* 136-byte string literal not displayed */
	Language   Language       `yaml:"language" mapstructure:"language" comment:"Language of the questions, zh or en"`
	LeetCode   LeetCodeConfig `yaml:"leetcode" mapstructure:"leetcode" comment:"LeetCode configuration"`
	Contest    ContestConfig  `yaml:"contest" mapstructure:"contest"`
	Editor     Editor         `yaml:"editor" mapstructure:"editor" comment:"The editor to open generated files"`
	Cache      string         `yaml:"cache" mapstructure:"cache" comment:"Cache type, json or sqlite"`
	Go         GoConfig       `yaml:"go" mapstructure:"go"`
	Python     BaseLangConfig `yaml:"python" mapstructure:"python"`
	Cpp        BaseLangConfig `yaml:"cpp" mapstructure:"cpp"`
	Java       BaseLangConfig `yaml:"java" mapstructure:"java"`
	Rust       BaseLangConfig `yaml:"rust" mapstructure:"rust"`
	C          BaseLangConfig `yaml:"c" mapstructure:"c"`
	CSharp     BaseLangConfig `yaml:"csharp" mapstructure:"csharp"`
	JavaScript BaseLangConfig `yaml:"javascript" mapstructure:"javascript"`
	Ruby       BaseLangConfig `yaml:"ruby" mapstructure:"ruby"`
	Swift      BaseLangConfig `yaml:"swift" mapstructure:"swift"`
	Kotlin     BaseLangConfig `yaml:"kotlin" mapstructure:"kotlin"`
	PHP        BaseLangConfig `yaml:"php" mapstructure:"php"`
	// contains filtered or unexported fields
}

func Default

func Default() *Config

func Get

func Get() *Config

func (*Config) ConfigDir

func (c *Config) ConfigDir() string

func (*Config) GlobalConfigFile

func (c *Config) GlobalConfigFile() string

func (*Config) LeetCodeCacheFile

func (c *Config) LeetCodeCacheFile() string

func (*Config) ProjectConfigFile

func (c *Config) ProjectConfigFile() string

func (*Config) ProjectConfigFilename

func (c *Config) ProjectConfigFilename() string

func (*Config) ProjectRoot

func (c *Config) ProjectRoot() string

func (*Config) Write

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

type ContestConfig

type ContestConfig struct {
	OutDir string `yaml:"out_dir" mapstructure:"out_dir" comment:"Base dir to put generated contest questions"`
}

type Credentials

type Credentials struct {
	ReadFromBrowser string `` /* 138-byte string literal not displayed */
	Session         string `yaml:"session,omitempty" mapstructure:"session" comment:"LeetCode cookie: LEETCODE_SESSION"`
	CsrfToken       string `yaml:"csrf_token,omitempty" mapstructure:"csrf_token" comment:"LeetCode cookie: csrftoken"`
	Username        string `yaml:"username,omitempty" mapstructure:"username" comment:"LeetCode username"`
	Password        string `yaml:"password,omitempty" mapstructure:"password" comment:"Encrypted LeetCode password"`
}

type Editor

type Editor struct {
	Command string   `yaml:"command" mapstructure:"command"`
	Args    []string `yaml:"args" mapstructure:"args"`
}

type GoConfig

type GoConfig struct {
	BaseLangConfig   `yaml:",inline" mapstructure:",squash"`
	SeparatePackage  bool   `yaml:"separate_package" mapstructure:"separate_package" comment:"Generate separate package for each question"`
	FilenameTemplate string `yaml:"filename_template" mapstructure:"filename_template" comment:"Filename template for Go files"`
}

type Language

type Language string

type LeetCodeConfig

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

type LeetcodeSite

type LeetcodeSite string

Jump to

Keyboard shortcuts

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