forked from IceWhaleTech/CasaOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
message-bus-codegen
CLI tool for generating a markdown of all e…
…vent types (IceWhaleTech#1346)
- Loading branch information
Showing
5 changed files
with
40 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/IceWhaleTech/CasaOS-Common/external" | ||
"github.com/IceWhaleTech/CasaOS/codegen/message_bus" | ||
"github.com/IceWhaleTech/CasaOS/common" | ||
"github.com/samber/lo" | ||
) | ||
|
||
func main() { | ||
eventTypes := lo.Map(common.EventTypes, func(item message_bus.EventType, index int) external.EventType { | ||
return external.EventType{ | ||
Name: item.Name, | ||
SourceID: item.SourceID, | ||
PropertyTypeList: lo.Map( | ||
item.PropertyTypeList, func(item message_bus.PropertyType, index int) external.PropertyType { | ||
return external.PropertyType{ | ||
Name: item.Name, | ||
Description: item.Description, | ||
Example: item.Example, | ||
} | ||
}, | ||
), | ||
} | ||
}) | ||
|
||
external.PrintEventTypesAsMarkdown(common.SERVICENAME, common.VERSION, eventTypes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
package common | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/IceWhaleTech/CasaOS/codegen/message_bus" | ||
) | ||
|
||
var ( | ||
// devtype -> action -> event | ||
EventTypes map[string]map[string]message_bus.EventType | ||
|
||
PropertyNameLookupMaps = map[string]map[string]string{ | ||
"system": { | ||
fmt.Sprintf("%s:%s", SERVICENAME, "utilization"): "ID_BUS", | ||
}, | ||
} | ||
|
||
ActionPastTense = map[string]string{ | ||
"add": "added", | ||
"remove": "removed", | ||
} | ||
) | ||
// devtype -> action -> event | ||
var EventTypes = []message_bus.EventType{ | ||
{Name: "casaos:system:utilization", SourceID: SERVICENAME, PropertyTypeList: []message_bus.PropertyType{}}, | ||
{Name: "casaos:file:recover", SourceID: SERVICENAME, PropertyTypeList: []message_bus.PropertyType{}}, | ||
{Name: "casaos:file:operate", SourceID: SERVICENAME, PropertyTypeList: []message_bus.PropertyType{}}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters