language

package
v0.0.0-...-41e44c1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecognizedNames

func RecognizedNames() []string

RecognizedNames returns all language names that are supported.

func RecognizedSupportedsNames

func RecognizedSupportedsNames() []string

RecognizedSupportedsNames returns all languages that are not "builtin" and also have a defined executable name.

func UnrecognizedLanguageError

func UnrecognizedLanguageError(name string, options []string) *locale.LocalizedError

UnrecognizedLanguageError simplifies construction of LocalizedError for an unrecognized language.

Types

type Executable

type Executable struct {
	// contains filtered or unexported fields
}

Executable contains details about an executable program used to interpret a Language.

func (Executable) Available

func (e Executable) Available() bool

Available returns whether the executable is not "builtin" and also has a defined name.

func (Executable) CanUseThirdParty

func (e Executable) CanUseThirdParty() bool

CanUseThirdParty expresses whether the executable is expected to be provided by the shell environment.

func (Executable) Filename

func (e Executable) Filename() string

Filename returns the executables file's full name.

func (Executable) Name

func (e Executable) Name() string

Name returns the executables file's name.

type Language

type Language int

Language tracks the languages potentially used.

const (
	Unset Language = iota
	Unknown
	Bash
	Sh
	Batch
	PowerShell
	Perl
	Python3
	Python2
	Ruby
)

Language constants are provided for safety/reference.

func MakeByName

func MakeByName(name string) Language

MakeByName will retrieve a language by a given name after lower-casing.

func MakeByNameAndVersion

func MakeByNameAndVersion(name, version string) Language

MakeByNameAndVersion will retrieve a language by a given name and version.

func MakeByShell

func MakeByShell(shell string) Language

MakeByShell returns either bash or cmd based on whether the provided shell name contains "cmd". This should be taken to mean that bash is a sort of default.

func MakeByText

func MakeByText(text string) Language

MakeByText will retrieve a language by a given text

func Recognized

func Recognized() []Language

Recognized returns all languages that are supported.

func (Language) Executable

func (l Language) Executable() Executable

Executable provides details about the executable related to the Language.

func (Language) Ext

func (l Language) Ext() string

Ext return the file extension for the language.

func (Language) Header

func (l Language) Header() string

Header returns the interpreter directive.

func (Language) MarshalYAML

func (l Language) MarshalYAML() (interface{}, error)

MarshalYAML implements the go-yaml/yaml.Marshaler interface.

func (*Language) Recognized

func (l *Language) Recognized() bool

Recognized returns whether the language is a known useful value.

func (Language) RecommendedVersion

func (l Language) RecommendedVersion() string

RecommendedVersion returns the string representation of the recommended version.

func (Language) Requirement

func (l Language) Requirement() string

Requirement returns the platform-level string representation.

func (*Language) Set

func (l *Language) Set(v string) error

Set implements the captain marshaler interfaces.

func (Language) String

func (l Language) String() string

String implements the fmt.Stringer interface.

func (Language) TempPattern

func (l Language) TempPattern() string

TempPattern returns the os.CreateTemp pattern to be used to form the temp file name.

func (Language) Text

func (l Language) Text() string

Text returns the human-readable value.

func (*Language) Type

func (l *Language) Type() string

Type implements the captain.FlagMarshaler interface.

func (*Language) UnmarshalYAML

func (l *Language) UnmarshalYAML(applyPayload func(interface{}) error) error

UnmarshalYAML implements the go-yaml/yaml.Unmarshaler interface.

func (*Language) Validate

func (l *Language) Validate() error

Validate ensures that the current language is recognized

type Supported

type Supported struct {
	Language
}

Supported tracks the languages potentially used for projects.

func RecognizedSupporteds

func RecognizedSupporteds() []Supported

RecognizedSupporteds returns all languages that are not "builtin" and also have a defined executable name.

func (*Supported) Recognized

func (l *Supported) Recognized() bool

Recognized returns whether the supported language is a known useful value.

func (*Supported) Set

func (l *Supported) Set(v string) error

Set implements the captain marshaler interfaces.

func (*Supported) UnmarshalYAML

func (l *Supported) UnmarshalYAML(applyPayload func(interface{}) error) error

UnmarshalYAML implements the go-yaml/yaml.Unmarshaler interface.

Jump to

Keyboard shortcuts

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