Help us shape the future of Go! Take the 2026 Go Developer Survey

execute

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:     "execute",
	Short:   "Execute a script",
	Example: `flow scripts execute --code=script.cdc --args="[{\"type\": \"String\", \"value\": \"Hello, Cadence\"}]"`,
	Run: func(cmd *cobra.Command, args []string) {
		code, err := ioutil.ReadFile(conf.Code)
		if err != nil {
			cli.Exitf(1, "Failed to read script from %s", conf.Code)
		}
		projectConf := new(cli.Config)
		if conf.Host == "" {
			projectConf = cli.LoadConfig()
		}

		// Arguments
		var scriptArguments []cadence.Value
		if conf.Args != "" {
			scriptArguments, err = cli.ParseArguments(conf.Args)
			if err != nil {
				cli.Exitf(1, "Invalid arguments passed: %s", conf.Args)
			}
		}

		cli.ExecuteScript(projectConf.HostWithOverride(conf.Host), code, scriptArguments...)
	},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Args string `default:"" flag:"args" info:"arguments in JSON-Cadence format"`
	Code string `flag:"code,c" info:"path to Cadence file"`
	Host string `flag:"host" info:"Flow Access API host address"`
}

Jump to

Keyboard shortcuts

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