diff --git a/actions/printer.go b/actions/printer.go index 6d6f487..a388896 100644 --- a/actions/printer.go +++ b/actions/printer.go @@ -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 { diff --git a/actions/shutdown.go b/actions/shutdown.go index 82a376b..0cd4818 100644 --- a/actions/shutdown.go +++ b/actions/shutdown.go @@ -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 { diff --git a/actions/timeout.go b/actions/timeout.go index 095b6ab..d78a14b 100644 --- a/actions/timeout.go +++ b/actions/timeout.go @@ -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 { diff --git a/actions/unix_command.go b/actions/unix_command.go index 19937e5..01775d5 100644 --- a/actions/unix_command.go +++ b/actions/unix_command.go @@ -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 { diff --git a/internal/config.go b/internal/config.go index 1737d31..60e8442 100644 --- a/internal/config.go +++ b/internal/config.go @@ -36,5 +36,6 @@ type ConfigOption struct { type Documenter interface { GetName() string GetDescription() string + GetExample() string GetOptions() []ConfigOption } diff --git a/triggers/ethernet.go b/triggers/ethernet.go index 0d9c4d3..dc4b24d 100644 --- a/triggers/ethernet.go +++ b/triggers/ethernet.go @@ -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"}, diff --git a/triggers/timeout.go b/triggers/timeout.go index 8717284..330c1aa 100644 --- a/triggers/timeout.go +++ b/triggers/timeout.go @@ -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 { diff --git a/triggers/usb.go b/triggers/usb.go index c09dfb5..297d8fd 100644 --- a/triggers/usb.go +++ b/triggers/usb.go @@ -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"},