1
0
mirror of https://github.com/directorz/mailfull-go.git synced 2025-12-21 11:37:07 +00:00

Change subcommand name: domainlist -> domains

This commit is contained in:
teru
2016-08-11 13:26:20 +09:00
parent 42d4e6389a
commit d7aac2d803
2 changed files with 7 additions and 7 deletions

View File

@@ -0,0 +1,55 @@
package command
import (
"fmt"
"sort"
"github.com/directorz/mailfull-go"
)
// DomainsCommand represents a DomainsCommand.
type DomainsCommand struct {
Meta
}
// Synopsis returns a one-line synopsis.
func (c *DomainsCommand) Synopsis() string {
return "Show domains."
}
// Help returns long-form help text.
func (c *DomainsCommand) Help() string {
txt := fmt.Sprintf(`
Usage:
%s %s
Description:
%s
`,
c.CmdName, c.SubCmdName,
c.Synopsis())
return txt[1:]
}
// Run runs the command and returns the exit status.
func (c *DomainsCommand) Run(args []string) int {
repo, err := mailfull.OpenRepository(".")
if err != nil {
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
return 1
}
domains, err := repo.Domains()
if err != nil {
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
return 1
}
sort.Sort(mailfull.DomainSlice(domains))
for _, domain := range domains {
fmt.Fprintf(c.UI.Writer, "%s\n", domain.Name())
}
return 0
}