lang

package
v0.0.0-...-3885f16 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Java

type Java struct {
}

func (Java) GetInfo

func (lang Java) GetInfo() LangInfo

func (Java) GetOutputFile

func (lang Java) GetOutputFile(values map[string]string, options types.GenerateOptions) string

func (Java) GetOutputFileName

func (lang Java) GetOutputFileName() string

func (Java) IsFilenameValid

func (lang Java) IsFilenameValid(filename string) bool

func (Java) ParseSourceCodeLine

func (lang Java) ParseSourceCodeLine(line string) []string

type Kotlin

type Kotlin struct {
}

func (Kotlin) GetInfo

func (lang Kotlin) GetInfo() LangInfo

func (Kotlin) GetOutputFile

func (lang Kotlin) GetOutputFile(values map[string]string, options types.GenerateOptions) string

func (Kotlin) GetOutputFileName

func (lang Kotlin) GetOutputFileName() string

func (Kotlin) IsFilenameValid

func (lang Kotlin) IsFilenameValid(filename string) bool

func (Kotlin) ParseSourceCodeLine

func (lang Kotlin) ParseSourceCodeLine(line string) []string

type Lang

type Lang interface {
	GetInfo() LangInfo
	// given a filename, determine if it's a valid filename for your programming language. If given `name.xml`, return false for Typescript. `.tsx` or `.ts` return true for Typescript.
	IsFilenameValid(filename string) bool
	// Given 1 line of code of your language, parse that to get all of the environment variables in that line. Example: For Kotlin if the line is `val foo = Env.bar + Env.fooBar + Env.foo` return ["BAR", "FOO_BAR", "BAR"]. Don't worry about duplicates those are removed for you.
	ParseSourceCodeLine(line string) []string
	// Filename to save the output code in. Example: `Env.java` for Java. `env.ts` for Typescript.
	GetOutputFileName() string
	// Generate a multi-line string that is the output source code with all of the environment variables inside. It's recommended you view the existing languages supported by this code base for examples as there are a lot of steps in this function.
	GetOutputFile(values map[string]string, options types.GenerateOptions) string
}

func GetAvailableLangs

func GetAvailableLangs() []Lang

NL: Add your new language below to the list. If your new language struct is named "Typescript", for example, add `Typescript{}` to the end of this list below.

func GetLang

func GetLang(langString string) (Lang, error)

NL: Add a case statement for your language.

func GetLangs

func GetLangs(langString string) ([]Lang, error)

Like GetLang(), but can handle an input string in the form of a list. Example: `java, kotlin`

type LangInfo

type LangInfo struct {
	// name of the language in lowercase and no spaces. If your programming language is Typescript, for example, return "typescript"
	Name string
	// Does your language require package names? (kotlin, java does)
	RequirePackageName bool
}

Information about the programming language. This is used by the CLI code to generate the CLI commands but is also used by each language's code generation file. Let's say your programming language requires that you enter a package name or module name at the top of the source code file. Then, add that new struct property below.

Jump to

Keyboard shortcuts

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