Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Generator] GM Command Generator Fixes #40

Merged
merged 5 commits into from
Jun 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions internal/console/command_doc_generator_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *GMCommandsDocsGenerateCommand) Handle(_ *cobra.Command, _ []string) {

commandData += "| Command | Description | Status Level |\n"

commandData = fmt.Sprintf("%v| :--- | :--- |\n", commandData)
commandData = fmt.Sprintf("%v| :--- | :--- | :--- |\n", commandData)

for _, line := range strings.Split(string(body), "\n") {
if strings.Contains(line, "command_add(\"") {
Expand All @@ -80,7 +80,7 @@ func (c *GMCommandsDocsGenerateCommand) Handle(_ *cobra.Command, _ []string) {

lineData := strings.Split(currentLine, "||")

statusValue := GetstatusValue(lineData[2])
statusValue := GetStatusValue(lineData[2])
statusName := strings.ReplaceAll(lineData[2], "AccountStatus::", "")

commandData += fmt.Sprintf("| #%v | %v | %v (%v) |\n", lineData[0], lineData[1], statusName, statusValue)
Expand All @@ -93,7 +93,7 @@ func (c *GMCommandsDocsGenerateCommand) Handle(_ *cobra.Command, _ []string) {
}
}

func GetstatusValue(StatusLevel string) int {
func GetStatusValue(statusLevel string) int {
m := map[string]int{
"AccountStatus::Player": 0,
"AccountStatus::Steward": 10,
Expand All @@ -114,5 +114,9 @@ func GetstatusValue(StatusLevel string) int {
"AccountStatus::Max": 255,
}

return m[StatusLevel]
if _, ok := m[statusLevel]; !ok {
return 0
}

return m[statusLevel]
}