Skip to content

Commit

Permalink
Update list domain CLI command to list deprecated domains (cadence-wo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll authored Mar 6, 2021
1 parent b399bd5 commit 1e8b738
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tools/cli/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ func newAdminDomainCommands() []cli.Command {
Name: FlagAllWithAlias,
Usage: "List all domains, by default only domains in REGISTERED status are listed",
},
cli.BoolFlag{
Name: FlagDeprecatedWithAlias,
Usage: "List deprecated domains only, by default only domains in REGISTERED status are listed",
},
cli.BoolFlag{
Name: FlagPrintFullyDetailWithAlias,
Usage: "Print full domain detail",
Expand Down
14 changes: 12 additions & 2 deletions tools/cli/domainCommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,16 +443,26 @@ func (d *domainCLIImpl) DescribeDomain(c *cli.Context) {
}

func (d *domainCLIImpl) ListDomains(c *cli.Context) {
domains := d.getAllDomains(c)
pageSize := c.Int(FlagPageSize)
printAll := c.Bool(FlagAll)
printDeprecated := c.Bool(FlagDeprecated)
printFull := c.Bool(FlagPrintFullyDetail)

if printAll && printDeprecated {
ErrorAndExit(fmt.Sprintf("Cannot specify %s and %s flags at the same time.", FlagAll, FlagDeprecated), nil)
}

domains := d.getAllDomains(c)

table := createTableForListDomains(printAll, printFull)

currentPageSize := 0
for i, domain := range domains {
if !printAll && *domain.DomainInfo.Status != types.DomainStatusRegistered {
if printDeprecated {
if *domain.DomainInfo.Status != types.DomainStatusDeprecated {
continue
}
} else if !printAll && *domain.DomainInfo.Status != types.DomainStatusRegistered {
continue
}

Expand Down
2 changes: 2 additions & 0 deletions tools/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ const (
FlagMoreWithAlias = FlagMore + ", m"
FlagAll = "all"
FlagAllWithAlias = FlagAll + ", a"
FlagDeprecated = "deprecated"
FlagDeprecatedWithAlias = FlagDeprecated + ", dep"
FlagPageSize = "pagesize"
FlagPageSizeWithAlias = FlagPageSize + ", ps"
FlagEarliestTime = "earliest_time"
Expand Down

0 comments on commit 1e8b738

Please sign in to comment.