Ejemplo n.º 1
0
func init() {
	core.Handler("context.push", Push)
	core.Handler("context.clear", Clear)

	// var pushDocs = `Values to push (if a map -- keys are current name and values are names to push under,` +
	// 	`if a string -- entire context is pushed under this name)`
	// core.Add("context.push", core.Function{
	// 	Description: "Pushes values to context",
	// 	Arguments: core.Variables{
	// 		"push": core.Interface(pushDocs, nil),
	// 	},
	// 	Returns: core.Variables{
	// 		"*": core.Interface("Pushed values", nil),
	// 	},
	// 	Function: Push,
	// })
	// core.Add("context.clear", core.Function{
	// 	Description: "Clear context and leave only values set in `context` argument",
	// 	Arguments: core.Variables{
	// 		"context": core.List("List of context variables NOT to clear", nil),
	// 	},
	// 	Returns: core.Variables{
	// 		"*": core.Interface("Variables defined by `context` argument values", nil),
	// 	},
	// 	Function: Clear,
	// })
}
Ejemplo n.º 2
0
func init() {
	core.Handler("actions.run", Run)
	core.Handler("actions.split", Split)

	// core.Add("actions.run", core.Function{
	// 	Description: "Runs action",
	// 	Arguments: core.Variables{
	// 		"name": core.String("Action name", ""),
	// 		"ctx":  core.Map("Action context", nil),
	// 		"next": core.Interface("Next action (map or string)", nil),
	// 	},
	// 	Returns: core.Variables{
	// 		"*": core.Interface("Action results", nil),
	// 	},
	// 	Function: Run,
	// })
	// core.Add("actions.split", core.Function{
	// 	Description: "Iterates through lists, launches actions and collects results",
	// 	Arguments: core.Variables{
	// 		"collect": core.Interface("What to collect (if empty everything is collected)", nil),
	// 		"split":   core.Map("What and how to split", nil),
	// 	},
	// 	Returns: core.Variables{
	// 		"*": core.Interface("Collected results", nil),
	// 	},
	// 	Function: Split,
	// })
}
Ejemplo n.º 3
0
func init() {
	core.Handler("json.decode", Decode)
	core.Handler("json.encode", Encode)

	// core.Add("json.decode", core.Function{
	// 	Description: "Decode JSON values",
	// 	Arguments: core.Variables{
	// 		"decode": core.Interface("Name, a list or a map of values to decode", nil),
	// 	},
	// 	Returns: core.Variables{
	// 		"*": core.Interface("Decoded values", nil),
	// 	},
	// 	Function: Decode,
	// })
	//
	// core.Add("json.encode", core.Function{
	// 	Description: "Encode JSON values",
	// 	Arguments: core.Variables{
	// 		"encode": core.Interface("Name, a list or a map of values to encode", nil),
	// 	},
	// 	Returns: core.Variables{
	// 		"*": core.Interface("Encoded values", nil),
	// 	},
	// 	Function: Encode,
	// })
}
Ejemplo n.º 4
0
func init() {
	core.Handler("http.request", Request)

	// Add http.request function to core
	// core.Add("http.request", core.Function{
	// 	Description: "Makes a HTTP request",
	// 	Arguments: core.Variables{
	// 		"hostname": core.String("Request hostname", ""),
	// 		"header":   core.Map("Request header", nil),
	// 		"scheme":   core.String("Request URL scheme (http or https)", "http"),
	// 		"method":   core.String("Request method", "GET"),
	// 		"query":    core.Interface("Request query (map or string)", nil),
	// 		"url":      core.String("Request URL", ""),
	// 	},
	// 	Returns: core.Variables{
	// 		"status": core.Int("Response status code", 0),
	// 		"header": core.Map("Response header", nil),
	// 		"body":   core.Stream("Response body"),
	// 	},
	// 	Function: Request,
	// })

	// Method shortcuts for http.request eq. http.get
	methods := []string{"get", "put", "post", "delete"}

	// Add all shortcuts
	for _, method := range methods {
		core.Action("http."+method, &action.Action{
			Name: "http.request",
			Ctx: action.Map{
				"method": strings.ToUpper(method),
			},
		})
	}
}
Ejemplo n.º 5
0
func init() {
	core.Handler("log.write", Write)

	// core.Add("log.write", core.Function{
	// 	Description: "Writes a log",
	// 	Arguments: core.Variables{
	// 		"body": core.String("Content to write", ""),
	// 	},
	// 	Function: Write,
	// })
}
Ejemplo n.º 6
0
func init() {
	core.Handler("filter.trim.spaces", TrimSpaces)

	// core.Add("filter.trim.spaces", core.Function{
	// 	Description: "Trim spaces from strings",
	// 	Arguments: core.Variables{
	// 		"trim": core.Interface("Name, a list or a map of values to trim", nil),
	// 	},
	// 	Returns: core.Variables{
	// 		"*": core.Interface("Action results", nil),
	// 	},
	// 	Function: trim_spaces,
	// })
}
Ejemplo n.º 7
0
func init() {
	core.Handler("regexp.extract", Extract)

	// core.Add("regexp.extract", core.Function{
	// 	Description: "Extracts regexp from text",
	// 	Arguments: core.Variables{
	// 		"regexp": core.Map("Regexp selectors", nil),
	// 	},
	// 	Returns: core.Variables{
	// 		"*": core.Interface("Extracted text", nil),
	// 	},
	// 	Function: Extract,
	// })
}
Ejemplo n.º 8
0
func init() {
	core.Handler("html.extract", Extract)

	// core.Add("html.extract", core.Function{
	// 	Description: "Extracts selectors from HTML body",
	// 	Arguments: core.Variables{
	// 		"selectors": core.Map("Selectors to extract from HTML body", nil),
	// 		"body":      core.Stream("HTML body"),
	// 	},
	// 	Returns: core.Variables{
	// 		"*": core.Interface("Extracted selectors", nil),
	// 	},
	// 	Function: Extract,
	// })
}
Ejemplo n.º 9
0
func init() {
	core.Handler("cmd.run", Run)
	// core.Add("cmd.run", core.Function{
	// 	Description: "Runs command",
	// 	Arguments: core.Variables{
	// 		"name": core.String("Command name", ""),
	// 		"args": core.Interface("Command arguments (string or list)", nil),
	// 	},
	// 	Returns: core.Variables{
	// 		"success": core.Bool("Execution state", false),
	// 		"output":  core.Interface("Command output", nil),
	// 		"time":    core.Map("Execution time (user & system)", nil),
	// 	},
	// 	Function: Run,
	// })
}