cmd

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

Copyright © 2022 Runar Kristoffersen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2022 NAME HERE <EMAIL ADDRESS>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var (
	CLI config
)

Functions

func BuildTranslationKeyFromApi

func BuildTranslationKeyFromApi(api Api, l logger.AppLogger, projectKeyLike, localeLike string) map[string]map[string]string

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func Flatten

func Flatten(m map[string]interface{}) map[string]interface{}

Flatten takes a map and returns a new one where nested maps are replaced by dot-delimited keys.

func FlattenExtendedProject

func FlattenExtendedProject(ep types.ExtendedProject, locales []string) (map[string]map[string]string, error)

func GetFileAndContent

func GetFileAndContent(dryRun bool, fn string, fi os.FileInfo) (f *os.File, content []byte, err error)

func PrettyPrinttFile added in v0.5.0

func PrettyPrinttFile(filepath string, content string) (string, error)

func ReplaceAllStringSubmatchFunc

func ReplaceAllStringSubmatchFunc(re *regexp.Regexp, str string, repl func([]string, int, int) string) string

Types

type Api

type Api struct {
	Headers http.Header
	DryRun  bool
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(l logger.AppLogger, endpoint string) Api

func (Api) Do added in v0.5.3

func (a Api) Do(r *http.Request, j interface{}) (*http.Response, error)

Do a http.request. If j is not nil, it will unmarshal to that destination

func (Api) Export

func (a Api) Export(projectName string, format string, locale string, writer io.Writer) error

func (Api) Import

func (a Api) Import(projectName string, kind string, locale string, reader io.Reader, dryRun bool) (*http.Response, handlers.ImportResult, error)

func (*Api) Login

func (a *Api) Login(username, password string) error

func (*Api) NewRequest added in v0.5.3

func (a *Api) NewRequest(method string, subpath string, body io.Reader) (*http.Request, error)

NewRequest is a thin wrapper around http.NewRequest

func (Api) ServerInfo added in v0.6.0

func (a Api) ServerInfo() (models.ServerInfo, error)

func (*Api) SetToken

func (a *Api) SetToken(token string)

type Injecter

type Injecter struct {
	Dir             string
	DryRun          bool
	OnReplaceCmd    string
	ExtensionFilter map[string]bool
	IgnoreFilter    []string
	Traverser       TraverserFunc
	Regex           *regexp.Regexp
	ReplacementFunc ReplacementFunc
	// contains filtered or unexported fields
}

func NewInjector

func NewInjector(
	l logger.AppLogger,
	dir string,
	dryRun bool,
	onReplace string,
	ignoreFilter []string,
	extFilter []string,
	regex *regexp.Regexp,
	replacementFunc ReplacementFunc,
	traverserFunc TraverserFunc,
) Injecter

func (Injecter) Inject

func (in Injecter) Inject() error

func (Injecter) VisitFile

func (in Injecter) VisitFile(fPath string, info fs.FileInfo) (bool, error)

type ReplacementFunc

type ReplacementFunc = func(groups []string) (s string, changed bool)

type TokenRestriction added in v0.5.0

type TokenRestriction struct {
	Offset        int
	AllowedTypes  []chroma.TokenType
	AllowedValues []string
	OrSet         []*TokenRestriction
}

func NewTokenRestriction added in v0.5.0

func NewTokenRestriction(offset int) *TokenRestriction

func (*TokenRestriction) AddType added in v0.5.0

func (t *TokenRestriction) AddType(type_ ...chroma.TokenType) *TokenRestriction

func (*TokenRestriction) AddValue added in v0.5.0

func (t *TokenRestriction) AddValue(v ...string) *TokenRestriction

func (TokenRestriction) Matches added in v0.5.0

func (t TokenRestriction) Matches(i int, tokens []chroma.Token) bool

func (*TokenRestriction) Or added in v0.5.0

type Tokenizer added in v0.5.0

type Tokenizer struct {
	FilePath string
	Lexer    chroma.Config
	// contains filtered or unexported fields
}

func TokenizeSourceFileContent added in v0.5.0

func TokenizeSourceFileContent(filepath string, content string) (Tokenizer, error)

func (Tokenizer) Concat added in v0.5.0

func (t Tokenizer) Concat() string

func (Tokenizer) IsChanged added in v0.5.0

func (t Tokenizer) IsChanged() bool

func (*Tokenizer) SetTokens added in v0.5.0

func (t *Tokenizer) SetTokens(tokens []chroma.Token)

func (Tokenizer) Tokens added in v0.5.0

func (t Tokenizer) Tokens() []chroma.Token

type TraverserFunc added in v0.5.0

type TraverserFunc = func(*Tokenizer)

Jump to

Keyboard shortcuts

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