scripts

package
v0.20.3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:              "scripts",
	Short:            "Utilities to execute scripts",
	TraverseChildren: true,
}
View Source
var ExecuteCommand = &command.Command{
	Cmd: &cobra.Command{
		Use:     "execute <filename>",
		Short:   "Execute a script",
		Example: `flow scripts execute script.cdc --arg String:"Meow" --arg String:"Woof"`,
		Args:    cobra.MaximumNArgs(1),
	},
	Flags: &scriptFlags,
	Run: func(
		cmd *cobra.Command,
		args []string,
		globalFlags command.GlobalFlags,
		services *services.Services,
	) (command.Result, error) {
		filename := ""
		if len(args) == 1 {
			filename = args[0]
		} else if scriptFlags.Code != "" {
			fmt.Println("⚠️  DEPRECATION WARNING: use filename as a command argument <filename>")
			filename = scriptFlags.Code
		} else {
			return nil, fmt.Errorf("provide a valide filename command argument")
		}

		if scriptFlags.Args != "" {
			fmt.Println("⚠️  DEPRECATION WARNING: use arg flag in Type:Value format or args-json for JSON format")

			if len(scriptFlags.Arg) == 0 && scriptFlags.ArgsJSON == "" {
				scriptFlags.ArgsJSON = scriptFlags.Args
			}
		}

		value, err := services.Scripts.Execute(
			filename,
			scriptFlags.Arg,
			scriptFlags.ArgsJSON,
			globalFlags.Network,
		)
		if err != nil {
			return nil, err
		}

		return &ScriptResult{value}, nil
	},
}

Functions

This section is empty.

Types

type ScriptResult

type ScriptResult struct {
	cadence.Value
}

func (*ScriptResult) JSON

func (r *ScriptResult) JSON() interface{}

JSON convert result to JSON

func (*ScriptResult) Oneliner

func (r *ScriptResult) Oneliner() string

Oneliner show result as one liner grep friendly

func (*ScriptResult) String

func (r *ScriptResult) String() string

String convert result to string

Jump to

Keyboard shortcuts

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