Skip to content

Commit bac7a22

Browse files
Adding search support
1 parent 203e2ac commit bac7a22

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

plugin/commands/search/search.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package search
2+
3+
import (
4+
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/plugin"
5+
"github.com/spf13/cobra"
6+
7+
. "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n"
8+
"github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata"
9+
)
10+
11+
func SetupCobraCommands(sl *metadata.SoftlayerCommand) *cobra.Command {
12+
cobraCmd := &cobra.Command{
13+
Use: "search",
14+
Short: T("Perform a query against the SoftLayer search database."),
15+
RunE: nil,
16+
}
17+
18+
cobraCmd.AddCommand(NewSearchTypesCommand(sl).Command)
19+
return cobraCmd
20+
}
21+
22+
func SearchNamespace() plugin.Namespace {
23+
return plugin.Namespace{
24+
ParentName: "sl",
25+
Name: "search",
26+
Description: T("Perform a query against the SoftLayer search database."),
27+
}
28+
}

plugin/commands/search/types.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package search
2+
3+
import (
4+
"fmt"
5+
"github.com/spf13/cobra"
6+
7+
. "github.ibm.com/SoftLayer/softlayer-cli/plugin/i18n"
8+
"github.ibm.com/SoftLayer/softlayer-cli/plugin/managers"
9+
"github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata"
10+
11+
)
12+
13+
type SearchTypesCommand struct {
14+
*metadata.SoftlayerCommand
15+
SearchManager managers.SearchManager
16+
Command *cobra.Command
17+
}
18+
19+
func NewSearchTypesCommand(sl *metadata.SoftlayerCommand) *SearchTypesCommand {
20+
thisCmd := &SearchTypesCommand{
21+
SoftlayerCommand: sl,
22+
SearchManager: managers.NewSearchManager(sl.Session),
23+
}
24+
cobraCmd := &cobra.Command{
25+
Use: "types",
26+
Short: T("Display searchable types."),
27+
Args: metadata.NoArgs,
28+
RunE: func(cmd *cobra.Command, args []string) error {
29+
return thisCmd.Run(args)
30+
},
31+
}
32+
33+
thisCmd.Command = cobraCmd
34+
return thisCmd
35+
36+
}
37+
38+
func (cmd *SearchTypesCommand) Run(args []string) error {
39+
40+
fmt.Printf("Search Types would go here\n")
41+
return nil
42+
}

plugin/plugin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/order"
4444
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/placementgroup"
4545
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/reports"
46+
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/search"
4647
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/security"
4748
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/securitygroup"
4849
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/subnet"
@@ -122,6 +123,7 @@ func Namespaces() []plugin.Namespace {
122123
licenses.LicensesNamespace(),
123124
loadbal.LoadbalNamespace(),
124125
nas.NasNetworkStorageNamespace(),
126+
search.SearchNamespace(),
125127
security.SecurityNamespace(),
126128
securitygroup.SecurityGroupNamespace(),
127129
subnet.SubnetNamespace(),
@@ -252,6 +254,7 @@ func GetTopCobraCommand(ui terminal.UI, session *session.Session) *cobra.Command
252254
cobraCmd.AddCommand(cdn.SetupCobraCommands(slCommand))
253255
cobraCmd.AddCommand(dns.SetupCobraCommands(slCommand))
254256
cobraCmd.AddCommand(order.SetupCobraCommands(slCommand))
257+
cobraCmd.AddCommand(search.SetupCobraCommands(slCommand))
255258
cobraCmd.AddCommand(security.SetupCobraCommands(slCommand))
256259
cobraCmd.AddCommand(ticket.SetupCobraCommands(slCommand))
257260
cobraCmd.AddCommand(placementgroup.SetupCobraCommands(slCommand))

0 commit comments

Comments
 (0)