Skip to content

Commit

Permalink
chore: add docs for resource types #440 (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan authored Mar 22, 2024
1 parent b443424 commit 11325d1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions internal/client/res/res.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (
"internal/apiclient"
)

// validResourceTypes contains a list of valid resources
var validResourceTypes = []string{"js", "jsc", "properties", "java", "wsdl", "xsd", "py", "xslt", "oas", "graphql"}

// Create
func Create(name string, resPath string, resourceType string) (respBody []byte, err error) {
if !validate(resourceType) {
Expand Down Expand Up @@ -100,13 +103,14 @@ func List(resourceType string) (respBody []byte, err error) {

// validate returns true is the resource type is valid
func validate(resType string) bool {
// validResourceTypes contains a list of valid resources
validResourceTypes := [10]string{"js", "jsc", "properties", "java", "wsdl", "xsd", "py", "xslt", "oas", "graphql"}

for _, n := range validResourceTypes {
if n == resType {
return true
}
}
return false
}

func GetValidResourceTypes() []string {
return validResourceTypes
}
3 changes: 2 additions & 1 deletion internal/cmd/res/crtres.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package res

import (
"internal/apiclient"
"strings"

"internal/client/res"

Expand Down Expand Up @@ -44,7 +45,7 @@ func init() {
CreateCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the resource file")
CreateCmd.Flags().StringVarP(&resType, "type", "p",
"", "Resource type; Valid types include java, js, jsc, properties, py, wsdl, xsd, or xsl.")
"", "Resource type; Valid types include "+strings.Join(res.GetValidResourceTypes(), ", "))
CreateCmd.Flags().StringVarP(&resPath, "respath", "",
"", "Resource Path")

Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/res/delres.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package res

import (
"internal/apiclient"
"strings"

"internal/client/res"

Expand All @@ -42,7 +43,7 @@ func init() {
DelCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the resource file")
DelCmd.Flags().StringVarP(&resType, "type", "p",
"", "Resource type")
"", "Resource type. Valid resource types include "+strings.Join(res.GetValidResourceTypes(), ", "))

_ = DelCmd.MarkFlagRequired("name")
_ = DelCmd.MarkFlagRequired("type")
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/res/getres.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package res

import (
"internal/apiclient"
"strings"

"internal/client/res"

Expand All @@ -41,7 +42,7 @@ func init() {
GetCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the resource file")
GetCmd.Flags().StringVarP(&resType, "type", "p",
"", "Resource type")
"", "Resource type. Valid resource types include "+strings.Join(res.GetValidResourceTypes(), ", "))

_ = GetCmd.MarkFlagRequired("name")
_ = GetCmd.MarkFlagRequired("type")
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/res/updres.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package res

import (
"internal/apiclient"
"strings"

"internal/client/res"

Expand All @@ -41,7 +42,7 @@ func init() {
UpdateCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the resource file")
UpdateCmd.Flags().StringVarP(&resType, "type", "p",
"", "Resource type. Valid types include java, js, jsc, properties, py, wsdl, xsd, or xsl.")
"", "Resource type. Valid types include "+strings.Join(res.GetValidResourceTypes(), ", "))
UpdateCmd.Flags().StringVarP(&resPath, "respath", "",
"", "Resource Path")

Expand Down

0 comments on commit 11325d1

Please sign in to comment.