[docs] add Examples to each trigger/action

This commit is contained in:
2023-10-31 00:41:59 +01:00
parent 06534e0bbd
commit 8898565ff8
8 changed files with 98 additions and 6 deletions

View File

@@ -39,7 +39,21 @@ func (p Printer) GetName() string {
}
func (p Printer) GetDescription() string {
return "When triggered prints the configured message to stdout"
return `
Prints a given message to stdout.
This action is mostly used for debugging purposes.
`
}
func (p Printer) GetExample() string {
return `
{
type: "Print",
"options: {
"message": "Hello World!"
}
}
`
}
func (p Printer) GetOptions() []internal.ConfigOption {

View File

@@ -37,7 +37,15 @@ func (p Shutdown) GetName() string {
}
func (p Shutdown) GetDescription() string {
return "When triggered shuts down the machine"
return "Shutsdown the machine by perfoming a ```shutdown -h now```"
}
func (p Shutdown) GetExample() string {
return `
{
"type": "Shutdown",
}
`
}
func (p Shutdown) GetOptions() []internal.ConfigOption {

View File

@@ -40,7 +40,21 @@ func (p TimeOut) GetName() string {
}
func (p TimeOut) GetDescription() string {
return "When triggered waits given duration before continuing with next stage"
return `
Waits given duration in seconds.
This can be used to wait a certain amount of time before continuing to the next Stage
`
}
func (p TimeOut) GetExample() string {
return `
{
"type": "Timeout",
"options": {
"duration": 5
}
}
`
}
func (p TimeOut) GetOptions() []internal.ConfigOption {

View File

@@ -82,7 +82,18 @@ func (p Command) GetName() string {
}
func (p Command) GetDescription() string {
return "When triggered executes given command"
return "Invoces given command using exec."
}
func (p Command) GetExample() string {
return `
{
"type": "Command",
"options": {
"command": "srm /path/to/file"
}
}
`
}
func (p Command) GetOptions() []internal.ConfigOption {

View File

@@ -36,5 +36,6 @@ type ConfigOption struct {
type Documenter interface {
GetName() string
GetDescription() string
GetExample() string
GetOptions() []ConfigOption
}

View File

@@ -87,6 +87,21 @@ func (p EthernetDisconnect) GetDescription() string {
return "Triggers if Ethernetcable is disconnected."
}
func (p EthernetDisconnect) GetExample() string {
return `
{
"type": "EthernetDisconnect",
"name": "Example Trigger",
"options": {
"interfaceName": "eth0",
"waitTillConnected": true
}
"actions": [
]
}
`
}
func (p EthernetDisconnect) GetOptions() []internal.ConfigOption {
return []internal.ConfigOption{
{"waitTillConnected", "bool", "Only trigger when device was connected before", "true"},

View File

@@ -1,5 +1,4 @@
package triggers
import (
"encoding/json"
"fmt"
@@ -45,7 +44,21 @@ func (p TimeOut) GetName() string {
}
func (p TimeOut) GetDescription() string {
return "Triggers after given duration."
return "Triggers after given duration. Mostly used for debugging."
}
func (p TimeOut) GetExample() string {
return `
{
"type": "Timeout",
"name": "Example Trigger",
"options": {
"duration": 5
}
"actions": [
]
}
`
}
func (p TimeOut) GetOptions() []internal.ConfigOption {

View File

@@ -88,6 +88,22 @@ func (p UsbDisconnect) GetDescription() string {
return "Triggers when given usb drive is disconnected"
}
func (p UsbDisconnect) GetExample() string {
return `
{
"type": "UsbDisconnect",
"name": "Example Trigger",
"options": {
"deviceId": "ata-Samsung_SSD_860_EVO_1TB_S4AALKWJDI102",
"waitTillConnected": true
}
"actions": [
]
}
`
}
func (p UsbDisconnect) GetOptions() []internal.ConfigOption {
return []internal.ConfigOption{
{"waitTillConnected", "bool", "Only trigger when device was connected before", "true"},