recast

package
v0.0.0-...-372bc1c Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildSubcommand = func(templateMap map[string]string) error {
	var getFirstMoveItem = func(templateMap map[string]string) (string, error) {
		moveItems := templateMap[globals.KEY_MOVE_ITEMS]
		moveItemParts := strings.Split(moveItems, ":")
		if len(moveItemParts) == 0 {
			err := fmt.Errorf("no move-item is available")
			return "", err
		}
		firstMoveItem := moveItemParts[0]
		return firstMoveItem, nil
	}
	var replaceFirstMoveItemFileNameWithToken = func(templateMap map[string]string) error {
		firstMoveItem, err := getFirstMoveItem(templateMap)
		if err != nil {
			return err
		}

		storePath := filepath.Join(templateMap[globals.KEY_ALTER_PATH], globals.STORE_DIRNAME)
		if !common.IsDir(storePath) {
			err := fmt.Errorf("store-path %s does not exist", storePath)
			return err
		}
		templateMap[globals.KEY_STORE_PATH] = storePath

		oldPath := filepath.Join(storePath, firstMoveItem)
		newPath := filepath.Join(storePath, "{{name}}")

		err = os.Rename(oldPath, newPath)
		if err != nil {
			return err
		}
		return nil
	}
	err := replaceFirstMoveItemFileNameWithToken(templateMap)
	if err != nil {
		return err
	}

	_, err = domain.BuildAlterInfrastucture(templateMap, QueryTemplate, ControlTemplate)
	return err
}
View Source
var (
	ControlTemplate = `
[
  {
	"op": "recast",
	"directives": {
	  "declare": {
		"name": "{{.FullQueryId}}"
	  }
	}
  }
]
`
)
View Source
var (
	QueryTemplate = `` /* 566-byte string literal not displayed */

)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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