Skip to content

Commit a6c27f3

Browse files
committed
fix: incorporate feedback on structuring of tools
1 parent 6a7b767 commit a6c27f3

10 files changed

Lines changed: 65 additions & 29 deletions

File tree

pkg/commands/commands.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package commands
22

33
import (
4-
"github.com/fastly/cli/pkg/commands/domainv1/tools"
54
"github.com/fastly/kingpin"
65

76
"github.com/fastly/cli/pkg/argparser"
@@ -79,6 +78,8 @@ import (
7978
tlscustomprivatekey "github.com/fastly/cli/pkg/commands/tls/custom/privatekey"
8079
tlsplatform "github.com/fastly/cli/pkg/commands/tls/platform"
8180
tlssubscription "github.com/fastly/cli/pkg/commands/tls/subscription"
81+
"github.com/fastly/cli/pkg/commands/tools"
82+
domainTools "github.com/fastly/cli/pkg/commands/tools/domain"
8283
"github.com/fastly/cli/pkg/commands/update"
8384
"github.com/fastly/cli/pkg/commands/user"
8485
"github.com/fastly/cli/pkg/commands/vcl"
@@ -204,9 +205,6 @@ func Define( // nolint:revive // function-length
204205
domainv1Delete := domainv1.NewDeleteCommand(domainv1CmdRoot.CmdClause, data)
205206
domainv1Describe := domainv1.NewDescribeCommand(domainv1CmdRoot.CmdClause, data)
206207
domainv1List := domainv1.NewListCommand(domainv1CmdRoot.CmdClause, data)
207-
domainv1ToolsCmdRoot := tools.NewRootCommand(domainv1CmdRoot.CmdClause, data)
208-
domainv1ToolsStatus := tools.NewDomainStatusCommand(domainv1ToolsCmdRoot.CmdClause, data)
209-
domainv1ToolsSuggestions := tools.NewDomainSuggestionsCommand(domainv1ToolsCmdRoot.CmdClause, data)
210208
domainv1Update := domainv1.NewUpdateCommand(domainv1CmdRoot.CmdClause, data)
211209
healthcheckCmdRoot := healthcheck.NewRootCommand(app, data)
212210
healthcheckCreate := healthcheck.NewCreateCommand(healthcheckCmdRoot.CmdClause, data)
@@ -490,6 +488,10 @@ func Define( // nolint:revive // function-length
490488
tlsSubscriptionDescribe := tlssubscription.NewDescribeCommand(tlsSubscriptionCmdRoot.CmdClause, data)
491489
tlsSubscriptionList := tlssubscription.NewListCommand(tlsSubscriptionCmdRoot.CmdClause, data)
492490
tlsSubscriptionUpdate := tlssubscription.NewUpdateCommand(tlsSubscriptionCmdRoot.CmdClause, data)
491+
toolsCmdRoot := tools.NewRootCommand(app, data)
492+
toolsDomainCmdRoot := domainTools.NewRootCommand(toolsCmdRoot.CmdClause, data)
493+
toolsDomainStatus := domainTools.NewDomainStatusCommand(toolsDomainCmdRoot.CmdClause, data)
494+
toolsDomainSuggestions := domainTools.NewDomainSuggestionsCommand(toolsDomainCmdRoot.CmdClause, data)
493495
updateRoot := update.NewRootCommand(app, data)
494496
userCmdRoot := user.NewRootCommand(app, data)
495497
userCreate := user.NewCreateCommand(userCmdRoot.CmdClause, data)
@@ -619,10 +621,7 @@ func Define( // nolint:revive // function-length
619621
domainv1Delete,
620622
domainv1Describe,
621623
domainv1List,
622-
domainv1ToolsCmdRoot,
623624
domainv1Update,
624-
domainv1ToolsStatus,
625-
domainv1ToolsSuggestions,
626625
healthcheckCmdRoot,
627626
healthcheckCreate,
628627
healthcheckDelete,
@@ -902,6 +901,10 @@ func Define( // nolint:revive // function-length
902901
tlsSubscriptionDescribe,
903902
tlsSubscriptionList,
904903
tlsSubscriptionUpdate,
904+
toolsCmdRoot,
905+
toolsDomainCmdRoot,
906+
toolsDomainStatus,
907+
toolsDomainSuggestions,
905908
updateRoot,
906909
userCmdRoot,
907910
userCreate,

pkg/commands/domainv1/tools/doc.go

Lines changed: 0 additions & 2 deletions
This file was deleted.

pkg/commands/tools/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package tools contains tools for working with the Fastly platform.
2+
package tools

pkg/commands/tools/domain/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package domain contains Domain Discovery API tools.
2+
package domain

pkg/commands/tools/domain/root.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package domain
2+
3+
import (
4+
"io"
5+
6+
"github.com/fastly/cli/pkg/argparser"
7+
"github.com/fastly/cli/pkg/global"
8+
)
9+
10+
// RootCommand is the parent command for all tool subcommands in this package.
11+
// It should be installed under the primary `tools` root command.
12+
type RootCommand struct {
13+
argparser.Base
14+
// no flags
15+
}
16+
17+
// CommandName is the string to be used to invoke this command.
18+
const CommandName = "domain"
19+
20+
// NewRootCommand returns a new tools command registered in the parent.
21+
func NewRootCommand(parent argparser.Registerer, g *global.Data) *RootCommand {
22+
var c RootCommand
23+
c.Globals = g
24+
c.CmdClause = parent.Command(CommandName, "Domain Discovery API tools")
25+
return &c
26+
}
27+
28+
// Exec implements the command interface.
29+
func (c *RootCommand) Exec(_ io.Reader, _ io.Writer) error {
30+
panic("unreachable")
31+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tools
1+
package domain
22

33
import (
44
"errors"
@@ -12,7 +12,7 @@ import (
1212
"github.com/fastly/go-fastly/v10/fastly/domains/v1/tools/status"
1313
)
1414

15-
// GetDomainStatusCommand calls the Fastly API to check the availability status of a domain.
15+
// GetDomainStatusCommand calls the Fastly API to check the availability of a domain name.
1616
type GetDomainStatusCommand struct {
1717
argparser.Base
1818
argparser.JSONOutput
@@ -30,12 +30,12 @@ func NewDomainStatusCommand(parent argparser.Registerer, g *global.Data) *GetDom
3030
},
3131
}
3232

33-
cmd.CmdClause = parent.Command("status", "Check the registration status of a single domain name.")
33+
cmd.CmdClause = parent.Command("status", "Check domain name availability")
3434
// Required.
3535
cmd.CmdClause.Arg("domain", "Domain name to check").Required().StringVar(&cmd.domain)
3636
// Optional.
3737
cmd.RegisterFlagBool(cmd.JSONFlag())
38-
cmd.CmdClause.Flag("scope", "Scope determines the availability check to perform, specify `estimate` for an estimated check").Action(cmd.scope.Set).StringVar(&cmd.scope.Value)
38+
cmd.CmdClause.Flag("scope", "Specify `--scope=estimate` to perform an “estimated” availability check, which checks the DNS and domain aftermarkets, not domain registries").Action(cmd.scope.Set).StringVar(&cmd.scope.Value)
3939

4040
return &cmd
4141
}

pkg/commands/domainv1/tools/status_test.go renamed to pkg/commands/tools/domain/status_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package tools_test
1+
package domain_test
22

33
import (
44
"bytes"
55
"io"
66
"net/http"
77
"testing"
88

9-
root "github.com/fastly/cli/pkg/commands/domainv1"
10-
"github.com/fastly/cli/pkg/commands/domainv1/tools"
9+
"github.com/fastly/cli/pkg/commands/tools"
10+
"github.com/fastly/cli/pkg/commands/tools/domain"
1111
"github.com/fastly/cli/pkg/testutil"
1212
"github.com/fastly/go-fastly/v10/fastly"
1313
"github.com/fastly/go-fastly/v10/fastly/domains/v1/tools/status"
@@ -121,5 +121,5 @@ Offers:
121121
`,
122122
},
123123
}
124-
testutil.RunCLIScenarios(t, []string{root.CommandName, tools.CommandName, "status"}, scenarios)
124+
testutil.RunCLIScenarios(t, []string{tools.CommandName, domain.CommandName, "status"}, scenarios)
125125
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tools
1+
package domain
22

33
import (
44
"errors"
@@ -14,7 +14,7 @@ import (
1414
"github.com/fastly/go-fastly/v10/fastly/domains/v1/tools/suggest"
1515
)
1616

17-
// GetDomainSuggestionsCommand calls the Fastly API to retrieve domain suggestions from the provided term(s).
17+
// GetDomainSuggestionsCommand calls the Fastly API and results domain search results for a given query
1818
type GetDomainSuggestionsCommand struct {
1919
argparser.Base
2020
argparser.JSONOutput
@@ -35,14 +35,14 @@ func NewDomainSuggestionsCommand(parent argparser.Registerer, g *global.Data) *G
3535
},
3636
}
3737

38-
cmd.CmdClause = parent.Command("suggest", "Performs real-time queries against the known zones database")
38+
cmd.CmdClause = parent.Command("suggest", "Returns domain search results for a given query")
3939
// Required.
40-
cmd.CmdClause.Arg("query", "Words to use for domain suggestions").Required().StringsVar(&cmd.query)
40+
cmd.CmdClause.Arg("query", "Search query, e.g. “acme coffee shop”").Required().StringsVar(&cmd.query)
4141
// Optional.
4242
cmd.CmdClause.Flag("defaults", "Comma-separated list of default zones to include in the search results response").Action(cmd.defaults.Set).StringVar(&cmd.defaults.Value)
4343
cmd.RegisterFlagBool(cmd.JSONFlag())
44-
cmd.CmdClause.Flag("keywords", "Comma-separated list of keywords for seeding the results").Action(cmd.keywords.Set).StringVar(&cmd.keywords.Value)
45-
cmd.CmdClause.Flag("location", "Overrides the IP location detection for country-code zones, with a two-character country code").Action(cmd.location.Set).StringVar(&cmd.location.Value)
44+
cmd.CmdClause.Flag("keywords", "Comma-separated list of keywords for seeding the search results").Action(cmd.keywords.Set).StringVar(&cmd.keywords.Value)
45+
cmd.CmdClause.Flag("location", "Override IP geolocation with a two-character country code, e.g. `--location=in` to include Indian domain zones in the search results").Action(cmd.location.Set).StringVar(&cmd.location.Value)
4646
cmd.CmdClause.Flag("vendor", "The domain name of a specific registrar or vendor ").Action(cmd.vendor.Set).StringVar(&cmd.vendor.Value)
4747

4848
return &cmd

pkg/commands/domainv1/tools/suggest_test.go renamed to pkg/commands/tools/domain/suggest_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package tools_test
1+
package domain_test
22

33
import (
44
"bytes"
55
"io"
66
"net/http"
77
"testing"
88

9-
root "github.com/fastly/cli/pkg/commands/domainv1"
10-
"github.com/fastly/cli/pkg/commands/domainv1/tools"
9+
"github.com/fastly/cli/pkg/commands/tools"
10+
"github.com/fastly/cli/pkg/commands/tools/domain"
1111
"github.com/fastly/cli/pkg/testutil"
1212
"github.com/fastly/go-fastly/v10/fastly"
1313
"github.com/fastly/go-fastly/v10/fastly/domains/v1/tools/suggest"
@@ -195,5 +195,5 @@ Path: /g
195195
`,
196196
},
197197
}
198-
testutil.RunCLIScenarios(t, []string{root.CommandName, tools.CommandName, "suggest"}, scenarios)
198+
testutil.RunCLIScenarios(t, []string{tools.CommandName, domain.CommandName, "suggest"}, scenarios)
199199
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
// RootCommand is the parent command for all tool subcommands in this package.
11-
// It should be installed under the primary `domainv1` root command.
11+
// It should be installed under the primary root command.
1212
type RootCommand struct {
1313
argparser.Base
1414
// no flags
@@ -21,7 +21,7 @@ const CommandName = "tools"
2121
func NewRootCommand(parent argparser.Registerer, g *global.Data) *RootCommand {
2222
var c RootCommand
2323
c.Globals = g
24-
c.CmdClause = parent.Command(CommandName, "Tools for domain discovery and operations")
24+
c.CmdClause = parent.Command(CommandName, "Tools for working with the Fastly platform")
2525
return &c
2626
}
2727

0 commit comments

Comments
 (0)