mirror of
https://github.com/directorz/mailfull-go.git
synced 2025-12-18 01:57:04 +00:00
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
mailfull "github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AliasDomainAddCommand represents a AliasDomainAddCommand.
|
// CmdAliasDomainAdd represents a CmdAliasDomainAdd.
|
||||||
type AliasDomainAddCommand struct {
|
type CmdAliasDomainAdd struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *AliasDomainAddCommand) Synopsis() string {
|
func (c *CmdAliasDomainAdd) Synopsis() string {
|
||||||
return "Create a new aliasdomain."
|
return "Create a new aliasdomain."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *AliasDomainAddCommand) Help() string {
|
func (c *CmdAliasDomainAdd) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] domain target
|
%s %s [-n] domain target
|
||||||
@@ -42,7 +43,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *AliasDomainAddCommand) Run(args []string) int {
|
func (c *CmdAliasDomainAdd) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -59,18 +60,18 @@ func (c *AliasDomainAddCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
aliasDomain, err := mailfull.NewAliasDomain(aliasDomainName, targetDomainName)
|
aliasDomain, err := mailfull.NewAliasDomain(aliasDomainName, targetDomainName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.AliasDomainCreate(aliasDomain); err != nil {
|
if err := repo.AliasDomainCreate(aliasDomain); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,13 +81,13 @@ func (c *AliasDomainAddCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
mailfull "github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AliasDomainDelCommand represents a AliasDomainDelCommand.
|
// CmdAliasDomainDel represents a CmdAliasDomainDel.
|
||||||
type AliasDomainDelCommand struct {
|
type CmdAliasDomainDel struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *AliasDomainDelCommand) Synopsis() string {
|
func (c *CmdAliasDomainDel) Synopsis() string {
|
||||||
return "Delete a aliasdomain."
|
return "Delete a aliasdomain."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *AliasDomainDelCommand) Help() string {
|
func (c *CmdAliasDomainDel) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] domain
|
%s %s [-n] domain
|
||||||
@@ -40,7 +41,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *AliasDomainDelCommand) Run(args []string) int {
|
func (c *CmdAliasDomainDel) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -56,12 +57,12 @@ func (c *AliasDomainDelCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.AliasDomainRemove(aliasDomainName); err != nil {
|
if err := repo.AliasDomainRemove(aliasDomainName); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,13 +72,13 @@ func (c *AliasDomainDelCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
mailfull "github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AliasDomainsCommand represents a AliasDomainsCommand.
|
// CmdAliasDomains represents a CmdAliasDomains.
|
||||||
type AliasDomainsCommand struct {
|
type CmdAliasDomains struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *AliasDomainsCommand) Synopsis() string {
|
func (c *CmdAliasDomains) Synopsis() string {
|
||||||
return "Show aliasdomains."
|
return "Show aliasdomains."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *AliasDomainsCommand) Help() string {
|
func (c *CmdAliasDomains) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [domain]
|
%s %s [domain]
|
||||||
@@ -37,7 +38,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *AliasDomainsCommand) Run(args []string) int {
|
func (c *CmdAliasDomains) Run(args []string) int {
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
return 1
|
return 1
|
||||||
@@ -50,13 +51,13 @@ func (c *AliasDomainsCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
aliasDomains, err := repo.AliasDomains()
|
aliasDomains, err := repo.AliasDomains()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
sort.Sort(mailfull.AliasDomainSlice(aliasDomains))
|
sort.Sort(mailfull.AliasDomainSlice(aliasDomains))
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
mailfull "github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AliasUserAddCommand represents a AliasUserAddCommand.
|
// CmdAliasUserAdd represents a CmdAliasUserAdd.
|
||||||
type AliasUserAddCommand struct {
|
type CmdAliasUserAdd struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *AliasUserAddCommand) Synopsis() string {
|
func (c *CmdAliasUserAdd) Synopsis() string {
|
||||||
return "Create a new aliasuser."
|
return "Create a new aliasuser."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *AliasUserAddCommand) Help() string {
|
func (c *CmdAliasUserAdd) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] address target [target...]
|
%s %s [-n] address target [target...]
|
||||||
@@ -43,7 +44,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *AliasUserAddCommand) Run(args []string) int {
|
func (c *CmdAliasUserAdd) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -68,18 +69,18 @@ func (c *AliasUserAddCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
aliasUser, err := mailfull.NewAliasUser(aliasUserName, targets)
|
aliasUser, err := mailfull.NewAliasUser(aliasUserName, targets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.AliasUserCreate(domainName, aliasUser); err != nil {
|
if err := repo.AliasUserCreate(domainName, aliasUser); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,13 +90,13 @@ func (c *AliasUserAddCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
mailfull "github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AliasUserDelCommand represents a AliasUserDelCommand.
|
// CmdAliasUserDel represents a CmdAliasUserDel.
|
||||||
type AliasUserDelCommand struct {
|
type CmdAliasUserDel struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *AliasUserDelCommand) Synopsis() string {
|
func (c *CmdAliasUserDel) Synopsis() string {
|
||||||
return "Delete a aliasuser."
|
return "Delete a aliasuser."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *AliasUserDelCommand) Help() string {
|
func (c *CmdAliasUserDel) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] address
|
%s %s [-n] address
|
||||||
@@ -41,7 +42,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *AliasUserDelCommand) Run(args []string) int {
|
func (c *CmdAliasUserDel) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -64,12 +65,12 @@ func (c *AliasUserDelCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.AliasUserRemove(domainName, aliasUserName); err != nil {
|
if err := repo.AliasUserRemove(domainName, aliasUserName); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,13 +80,13 @@ func (c *AliasUserDelCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
mailfull "github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AliasUserModCommand represents a AliasUserModCommand.
|
// CmdAliasUserMod represents a CmdAliasUserMod.
|
||||||
type AliasUserModCommand struct {
|
type CmdAliasUserMod struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *AliasUserModCommand) Synopsis() string {
|
func (c *CmdAliasUserMod) Synopsis() string {
|
||||||
return "Modify a aliasuser."
|
return "Modify a aliasuser."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *AliasUserModCommand) Help() string {
|
func (c *CmdAliasUserMod) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] address target [target...]
|
%s %s [-n] address target [target...]
|
||||||
@@ -43,7 +44,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *AliasUserModCommand) Run(args []string) int {
|
func (c *CmdAliasUserMod) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -68,27 +69,27 @@ func (c *AliasUserModCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
aliasUser, err := repo.AliasUser(domainName, aliasUserName)
|
aliasUser, err := repo.AliasUser(domainName, aliasUserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if aliasUser == nil {
|
if aliasUser == nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", mailfull.ErrAliasUserNotExist)
|
c.Meta.Errorf("%v\n", mailfull.ErrAliasUserNotExist)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := aliasUser.SetTargets(targets); err != nil {
|
if err := aliasUser.SetTargets(targets); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.AliasUserUpdate(domainName, aliasUser); err != nil {
|
if err := repo.AliasUserUpdate(domainName, aliasUser); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,13 +99,13 @@ func (c *AliasUserModCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AliasUsersCommand represents a AliasUsersCommand.
|
// CmdAliasUsers represents a CmdAliasUsers.
|
||||||
type AliasUsersCommand struct {
|
type CmdAliasUsers struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *AliasUsersCommand) Synopsis() string {
|
func (c *CmdAliasUsers) Synopsis() string {
|
||||||
return "Show aliasusers."
|
return "Show aliasusers."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *AliasUsersCommand) Help() string {
|
func (c *CmdAliasUsers) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s domain
|
%s %s domain
|
||||||
@@ -37,7 +38,7 @@ Required Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *AliasUsersCommand) Run(args []string) int {
|
func (c *CmdAliasUsers) Run(args []string) int {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
return 1
|
return 1
|
||||||
@@ -47,13 +48,13 @@ func (c *AliasUsersCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
aliasUsers, err := repo.AliasUsers(targetDomainName)
|
aliasUsers, err := repo.AliasUsers(targetDomainName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
sort.Sort(mailfull.AliasUserSlice(aliasUsers))
|
sort.Sort(mailfull.AliasUserSlice(aliasUsers))
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CatchAllCommand represents a CatchAllCommand.
|
// CmdCatchAll represents a CmdCatchAll.
|
||||||
type CatchAllCommand struct {
|
type CmdCatchAll struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *CatchAllCommand) Synopsis() string {
|
func (c *CmdCatchAll) Synopsis() string {
|
||||||
return "Show a catchall user."
|
return "Show a catchall user."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *CatchAllCommand) Help() string {
|
func (c *CmdCatchAll) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s domain
|
%s %s domain
|
||||||
@@ -36,7 +37,7 @@ Required Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *CatchAllCommand) Run(args []string) int {
|
func (c *CmdCatchAll) Run(args []string) int {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
return 1
|
return 1
|
||||||
@@ -46,13 +47,13 @@ func (c *CatchAllCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
catchAllUser, err := repo.CatchAllUser(domainName)
|
catchAllUser, err := repo.CatchAllUser(domainName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CatchAllSetCommand represents a CatchAllSetCommand.
|
// CmdCatchAllSet represents a CmdCatchAllSet.
|
||||||
type CatchAllSetCommand struct {
|
type CmdCatchAllSet struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *CatchAllSetCommand) Synopsis() string {
|
func (c *CmdCatchAllSet) Synopsis() string {
|
||||||
return "Set a catchall user."
|
return "Set a catchall user."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *CatchAllSetCommand) Help() string {
|
func (c *CmdCatchAllSet) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] domain user
|
%s %s [-n] domain user
|
||||||
@@ -42,7 +43,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *CatchAllSetCommand) Run(args []string) int {
|
func (c *CmdCatchAllSet) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -59,18 +60,18 @@ func (c *CatchAllSetCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
catchAllUser, err := mailfull.NewCatchAllUser(userName)
|
catchAllUser, err := mailfull.NewCatchAllUser(userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.CatchAllUserSet(domainName, catchAllUser); err != nil {
|
if err := repo.CatchAllUserSet(domainName, catchAllUser); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,13 +81,13 @@ func (c *CatchAllSetCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CatchAllUnsetCommand represents a CatchAllUnsetCommand.
|
// CmdCatchAllUnset represents a CmdCatchAllUnset.
|
||||||
type CatchAllUnsetCommand struct {
|
type CmdCatchAllUnset struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *CatchAllUnsetCommand) Synopsis() string {
|
func (c *CmdCatchAllUnset) Synopsis() string {
|
||||||
return "Unset a catchall user."
|
return "Unset a catchall user."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *CatchAllUnsetCommand) Help() string {
|
func (c *CmdCatchAllUnset) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] domain
|
%s %s [-n] domain
|
||||||
@@ -40,7 +41,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *CatchAllUnsetCommand) Run(args []string) int {
|
func (c *CmdCatchAllUnset) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -56,12 +57,12 @@ func (c *CatchAllUnsetCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.CatchAllUserUnset(domainName); err != nil {
|
if err := repo.CatchAllUserUnset(domainName); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,13 +72,13 @@ func (c *CatchAllUnsetCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CommitCommand represents a CommitCommand.
|
// CmdCommit represents a CmdCommit.
|
||||||
type CommitCommand struct {
|
type CmdCommit struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *CommitCommand) Synopsis() string {
|
func (c *CmdCommit) Synopsis() string {
|
||||||
return "Create databases from the structure of the MailData directory."
|
return "Create databases from the structure of the MailData directory."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *CommitCommand) Help() string {
|
func (c *CmdCommit) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s
|
%s %s
|
||||||
@@ -32,22 +33,22 @@ Description:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *CommitCommand) Run(args []string) int {
|
func (c *CmdCommit) Run(args []string) int {
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DomainAddCommand represents a DomainAddCommand.
|
// CmdDomainAdd represents a CmdDomainAdd.
|
||||||
type DomainAddCommand struct {
|
type CmdDomainAdd struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *DomainAddCommand) Synopsis() string {
|
func (c *CmdDomainAdd) Synopsis() string {
|
||||||
return "Create a new domain and postmaster."
|
return "Create a new domain and postmaster."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *DomainAddCommand) Help() string {
|
func (c *CmdDomainAdd) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] domain
|
%s %s [-n] domain
|
||||||
@@ -40,7 +41,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *DomainAddCommand) Run(args []string) int {
|
func (c *CmdDomainAdd) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -56,29 +57,29 @@ func (c *DomainAddCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
domain, err := mailfull.NewDomain(domainName)
|
domain, err := mailfull.NewDomain(domainName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.DomainCreate(domain); err != nil {
|
if err := repo.DomainCreate(domain); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := mailfull.NewUser("postmaster", mailfull.NeverMatchHashedPassword, nil)
|
user, err := mailfull.NewUser("postmaster", mailfull.NeverMatchHashedPassword, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.UserCreate(domainName, user); err != nil {
|
if err := repo.UserCreate(domainName, user); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,13 +89,13 @@ func (c *DomainAddCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DomainDelCommand represents a DomainDelCommand.
|
// CmdDomainDel represents a CmdDomainDel.
|
||||||
type DomainDelCommand struct {
|
type CmdDomainDel struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *DomainDelCommand) Synopsis() string {
|
func (c *CmdDomainDel) Synopsis() string {
|
||||||
return "Delete and backup a domain."
|
return "Delete and backup a domain."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *DomainDelCommand) Help() string {
|
func (c *CmdDomainDel) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] domain
|
%s %s [-n] domain
|
||||||
@@ -40,7 +41,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *DomainDelCommand) Run(args []string) int {
|
func (c *CmdDomainDel) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -56,12 +57,12 @@ func (c *DomainDelCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.DomainRemove(domainName); err != nil {
|
if err := repo.DomainRemove(domainName); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,13 +72,13 @@ func (c *DomainDelCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DomainDisableCommand represents a DomainDisableCommand.
|
// CmdDomainDisable represents a CmdDomainDisable.
|
||||||
type DomainDisableCommand struct {
|
type CmdDomainDisable struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *DomainDisableCommand) Synopsis() string {
|
func (c *CmdDomainDisable) Synopsis() string {
|
||||||
return "Disable a domain temporarily."
|
return "Disable a domain temporarily."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *DomainDisableCommand) Help() string {
|
func (c *CmdDomainDisable) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] domain
|
%s %s [-n] domain
|
||||||
@@ -40,7 +41,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *DomainDisableCommand) Run(args []string) int {
|
func (c *CmdDomainDisable) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -56,24 +57,24 @@ func (c *DomainDisableCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
domain, err := repo.Domain(domainName)
|
domain, err := repo.Domain(domainName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if domain == nil {
|
if domain == nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", mailfull.ErrDomainNotExist)
|
c.Meta.Errorf("%v\n", mailfull.ErrDomainNotExist)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
domain.SetDisabled(true)
|
domain.SetDisabled(true)
|
||||||
|
|
||||||
if err := repo.DomainUpdate(domain); err != nil {
|
if err := repo.DomainUpdate(domain); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,13 +84,13 @@ func (c *DomainDisableCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DomainEnableCommand represents a DomainEnableCommand.
|
// CmdDomainEnable represents a CmdDomainEnable.
|
||||||
type DomainEnableCommand struct {
|
type CmdDomainEnable struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *DomainEnableCommand) Synopsis() string {
|
func (c *CmdDomainEnable) Synopsis() string {
|
||||||
return "Enable a domain."
|
return "Enable a domain."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *DomainEnableCommand) Help() string {
|
func (c *CmdDomainEnable) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] domain
|
%s %s [-n] domain
|
||||||
@@ -40,7 +41,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *DomainEnableCommand) Run(args []string) int {
|
func (c *CmdDomainEnable) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -56,24 +57,24 @@ func (c *DomainEnableCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
domain, err := repo.Domain(domainName)
|
domain, err := repo.Domain(domainName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if domain == nil {
|
if domain == nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", mailfull.ErrDomainNotExist)
|
c.Meta.Errorf("%v\n", mailfull.ErrDomainNotExist)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
domain.SetDisabled(false)
|
domain.SetDisabled(false)
|
||||||
|
|
||||||
if err := repo.DomainUpdate(domain); err != nil {
|
if err := repo.DomainUpdate(domain); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,13 +84,13 @@ func (c *DomainEnableCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DomainsCommand represents a DomainsCommand.
|
// CmdDomains represents a CmdDomains.
|
||||||
type DomainsCommand struct {
|
type CmdDomains struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *DomainsCommand) Synopsis() string {
|
func (c *CmdDomains) Synopsis() string {
|
||||||
return "Show domains."
|
return "Show domains."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *DomainsCommand) Help() string {
|
func (c *CmdDomains) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s
|
%s %s
|
||||||
@@ -34,16 +35,16 @@ Description:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *DomainsCommand) Run(args []string) int {
|
func (c *CmdDomains) Run(args []string) int {
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
domains, err := repo.Domains()
|
domains, err := repo.Domains()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
sort.Sort(mailfull.DomainSlice(domains))
|
sort.Sort(mailfull.DomainSlice(domains))
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GenConfigCommand represents a GenConfigCommand.
|
// CmdGenConfig represents a CmdGenConfig.
|
||||||
type GenConfigCommand struct {
|
type CmdGenConfig struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *GenConfigCommand) Synopsis() string {
|
func (c *CmdGenConfig) Synopsis() string {
|
||||||
return "Write a Postfix or Dovecot configuration to stdout."
|
return "Write a Postfix or Dovecot configuration to stdout."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *GenConfigCommand) Help() string {
|
func (c *CmdGenConfig) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s name
|
%s %s name
|
||||||
@@ -37,7 +38,7 @@ Required Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *GenConfigCommand) Run(args []string) int {
|
func (c *CmdGenConfig) Run(args []string) int {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
return 1
|
return 1
|
||||||
@@ -47,7 +48,7 @@ func (c *GenConfigCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ func (c *GenConfigCommand) Run(args []string) int {
|
|||||||
fmt.Fprintf(c.UI.Writer, "%s", repo.GenerateConfigDovecot())
|
fmt.Fprintf(c.UI.Writer, "%s", repo.GenerateConfigDovecot())
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] Specify \"postfix\" or \"dovecot\".\n")
|
c.Meta.Errorf("Specify \"postfix\" or \"dovecot\".\n")
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitCommand represents a InitCommand.
|
// CmdInit represents a CmdInit.
|
||||||
type InitCommand struct {
|
type CmdInit struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *InitCommand) Synopsis() string {
|
func (c *CmdInit) Synopsis() string {
|
||||||
return "Initializes current directory as a Mailfull repository."
|
return "Initializes current directory as a Mailfull repository."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *InitCommand) Help() string {
|
func (c *CmdInit) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s
|
%s %s
|
||||||
@@ -32,9 +33,9 @@ Description:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *InitCommand) Run(args []string) int {
|
func (c *CmdInit) Run(args []string) int {
|
||||||
if err := mailfull.InitRepository("."); err != nil {
|
if err := mailfull.InitRepository("."); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserAddCommand represents a UserAddCommand.
|
// CmdUserAdd represents a CmdUserAdd.
|
||||||
type UserAddCommand struct {
|
type CmdUserAdd struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *UserAddCommand) Synopsis() string {
|
func (c *CmdUserAdd) Synopsis() string {
|
||||||
return "Create a new user."
|
return "Create a new user."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *UserAddCommand) Help() string {
|
func (c *CmdUserAdd) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] address
|
%s %s [-n] address
|
||||||
@@ -41,7 +42,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *UserAddCommand) Run(args []string) int {
|
func (c *CmdUserAdd) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -65,18 +66,18 @@ func (c *UserAddCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := mailfull.NewUser(userName, mailfull.NeverMatchHashedPassword, nil)
|
user, err := mailfull.NewUser(userName, mailfull.NeverMatchHashedPassword, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.UserCreate(domainName, user); err != nil {
|
if err := repo.UserCreate(domainName, user); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,13 +87,13 @@ func (c *UserAddCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,25 +1,26 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
"github.com/jsimonetti/pwscheme/ssha"
|
"github.com/jsimonetti/pwscheme/ssha"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserCheckPwCommand represents a UserCheckPwCommand.
|
// CmdUserCheckPw represents a CmdUserCheckPw.
|
||||||
type UserCheckPwCommand struct {
|
type CmdUserCheckPw struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *UserCheckPwCommand) Synopsis() string {
|
func (c *CmdUserCheckPw) Synopsis() string {
|
||||||
return "Check user's password."
|
return "Check user's password."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *UserCheckPwCommand) Help() string {
|
func (c *CmdUserCheckPw) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s address [password]
|
%s %s address [password]
|
||||||
@@ -43,7 +44,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *UserCheckPwCommand) Run(args []string) int {
|
func (c *CmdUserCheckPw) Run(args []string) int {
|
||||||
if len(args) != 1 && len(args) != 2 {
|
if len(args) != 1 && len(args) != 2 {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
return 1
|
return 1
|
||||||
@@ -66,24 +67,24 @@ func (c *UserCheckPwCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := repo.User(domainName, userName)
|
user, err := repo.User(domainName, userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if user == nil {
|
if user == nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", mailfull.ErrUserNotExist)
|
c.Meta.Errorf("%v\n", mailfull.ErrUserNotExist)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) != 2 {
|
if len(args) != 2 {
|
||||||
input, err := c.UI.AskSecret(fmt.Sprintf("Enter password for %s:", address))
|
input, err := c.UI.AskSecret(fmt.Sprintf("Enter password for %s:", address))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserDelCommand represents a UserDelCommand.
|
// CmdUserDel represents a CmdUserDel.
|
||||||
type UserDelCommand struct {
|
type CmdUserDel struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *UserDelCommand) Synopsis() string {
|
func (c *CmdUserDel) Synopsis() string {
|
||||||
return "Delete and backup a user."
|
return "Delete and backup a user."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *UserDelCommand) Help() string {
|
func (c *CmdUserDel) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] address
|
%s %s [-n] address
|
||||||
@@ -41,7 +42,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *UserDelCommand) Run(args []string) int {
|
func (c *CmdUserDel) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -65,17 +66,17 @@ func (c *UserDelCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if userName == "postmaster" {
|
if userName == "postmaster" {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] Cannot delete postmaster.\n")
|
c.Meta.Errorf("Cannot delete postmaster.\n")
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.UserRemove(domainName, userName); err != nil {
|
if err := repo.UserRemove(domainName, userName); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,13 +86,13 @@ func (c *UserDelCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,25 +1,26 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
"github.com/jsimonetti/pwscheme/ssha"
|
"github.com/jsimonetti/pwscheme/ssha"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserPasswdCommand represents a UserPasswdCommand.
|
// CmdUserPasswd represents a CmdUserPasswd.
|
||||||
type UserPasswdCommand struct {
|
type CmdUserPasswd struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *UserPasswdCommand) Synopsis() string {
|
func (c *CmdUserPasswd) Synopsis() string {
|
||||||
return "Update user's password."
|
return "Update user's password."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *UserPasswdCommand) Help() string {
|
func (c *CmdUserPasswd) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s [-n] address [password]
|
%s %s [-n] address [password]
|
||||||
@@ -45,7 +46,7 @@ Optional Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *UserPasswdCommand) Run(args []string) int {
|
func (c *CmdUserPasswd) Run(args []string) int {
|
||||||
noCommit, err := noCommitFlag(&args)
|
noCommit, err := noCommitFlag(&args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
@@ -74,33 +75,33 @@ func (c *UserPasswdCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := repo.User(domainName, userName)
|
user, err := repo.User(domainName, userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if user == nil {
|
if user == nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", mailfull.ErrUserNotExist)
|
c.Meta.Errorf("%v\n", mailfull.ErrUserNotExist)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) != 2 {
|
if len(args) != 2 {
|
||||||
input1, err := c.UI.AskSecret(fmt.Sprintf("Enter new password for %s:", address))
|
input1, err := c.UI.AskSecret(fmt.Sprintf("Enter new password for %s:", address))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
input2, err := c.UI.AskSecret("Retype new password:")
|
input2, err := c.UI.AskSecret("Retype new password:")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if input1 != input2 {
|
if input1 != input2 {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] inputs do not match.\n")
|
c.Meta.Errorf("inputs do not match.\n")
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
rawPassword = input1
|
rawPassword = input1
|
||||||
@@ -110,7 +111,7 @@ func (c *UserPasswdCommand) Run(args []string) int {
|
|||||||
if rawPassword != "" {
|
if rawPassword != "" {
|
||||||
str, err := ssha.Generate(rawPassword, 4)
|
str, err := ssha.Generate(rawPassword, 4)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
hashedPassword = str
|
hashedPassword = str
|
||||||
@@ -119,7 +120,7 @@ func (c *UserPasswdCommand) Run(args []string) int {
|
|||||||
user.SetHashedPassword(hashedPassword)
|
user.SetHashedPassword(hashedPassword)
|
||||||
|
|
||||||
if err := repo.UserUpdate(domainName, user); err != nil {
|
if err := repo.UserUpdate(domainName, user); err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,13 +130,13 @@ func (c *UserPasswdCommand) Run(args []string) int {
|
|||||||
|
|
||||||
mailData, err := repo.MailData()
|
mailData, err := repo.MailData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.GenerateDatabases(mailData)
|
err = repo.GenerateDatabases(mailData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
package command
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UsersCommand represents a UsersCommand.
|
// CmdUsers represents a CmdUsers.
|
||||||
type UsersCommand struct {
|
type CmdUsers struct {
|
||||||
Meta
|
cmd.Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synopsis returns a one-line synopsis.
|
// Synopsis returns a one-line synopsis.
|
||||||
func (c *UsersCommand) Synopsis() string {
|
func (c *CmdUsers) Synopsis() string {
|
||||||
return "Show users."
|
return "Show users."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns long-form help text.
|
// Help returns long-form help text.
|
||||||
func (c *UsersCommand) Help() string {
|
func (c *CmdUsers) Help() string {
|
||||||
txt := fmt.Sprintf(`
|
txt := fmt.Sprintf(`
|
||||||
Usage:
|
Usage:
|
||||||
%s %s domain
|
%s %s domain
|
||||||
@@ -37,7 +38,7 @@ Required Args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the command and returns the exit status.
|
// Run runs the command and returns the exit status.
|
||||||
func (c *UsersCommand) Run(args []string) int {
|
func (c *CmdUsers) Run(args []string) int {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help())
|
||||||
return 1
|
return 1
|
||||||
@@ -47,13 +48,13 @@ func (c *UsersCommand) Run(args []string) int {
|
|||||||
|
|
||||||
repo, err := mailfull.OpenRepository(".")
|
repo, err := mailfull.OpenRepository(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
users, err := repo.Users(targetDomainName)
|
users, err := repo.Users(targetDomainName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
|
c.Meta.Errorf("%v\n", err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
sort.Sort(mailfull.UserSlice(users))
|
sort.Sort(mailfull.UserSlice(users))
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package command
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"flag"
|
|
||||||
|
|
||||||
"github.com/mitchellh/cli"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Meta is for `*Command` struct.
|
|
||||||
type Meta struct {
|
|
||||||
UI *cli.BasicUi
|
|
||||||
CmdName string
|
|
||||||
SubCmdName string
|
|
||||||
Version string
|
|
||||||
}
|
|
||||||
|
|
||||||
// noCommitFlag returns true if `pargs` has "-n" flag.
|
|
||||||
// `pargs` is overwrites with non-flag arguments.
|
|
||||||
func noCommitFlag(pargs *[]string) (bool, error) {
|
|
||||||
nFlag := false
|
|
||||||
|
|
||||||
flagSet := flag.NewFlagSet("", flag.ContinueOnError)
|
|
||||||
flagSet.SetOutput(&bytes.Buffer{})
|
|
||||||
flagSet.BoolVar(&nFlag, "n", nFlag, "")
|
|
||||||
err := flagSet.Parse(*pargs)
|
|
||||||
*pargs = flagSet.Args()
|
|
||||||
|
|
||||||
return nFlag, err
|
|
||||||
}
|
|
||||||
@@ -4,12 +4,14 @@ Command mailfull is a CLI application using the mailfull package.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/directorz/mailfull-go"
|
"github.com/directorz/mailfull-go"
|
||||||
"github.com/directorz/mailfull-go/cmd/mailfull/command"
|
"github.com/directorz/mailfull-go/cmd"
|
||||||
"github.com/mitchellh/cli"
|
"github.com/mitchellh/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ func main() {
|
|||||||
Args: os.Args[1:],
|
Args: os.Args[1:],
|
||||||
}
|
}
|
||||||
|
|
||||||
meta := command.Meta{
|
meta := cmd.Meta{
|
||||||
UI: &cli.BasicUi{
|
UI: &cli.BasicUi{
|
||||||
Reader: os.Stdin,
|
Reader: os.Stdin,
|
||||||
Writer: os.Stdout,
|
Writer: os.Stdout,
|
||||||
@@ -44,95 +46,95 @@ func main() {
|
|||||||
c.Commands = map[string]cli.CommandFactory{
|
c.Commands = map[string]cli.CommandFactory{
|
||||||
"init": func() (cli.Command, error) {
|
"init": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.InitCommand{Meta: meta}, nil
|
return &CmdInit{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"genconfig": func() (cli.Command, error) {
|
"genconfig": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.GenConfigCommand{Meta: meta}, nil
|
return &CmdGenConfig{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"domains": func() (cli.Command, error) {
|
"domains": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.DomainsCommand{Meta: meta}, nil
|
return &CmdDomains{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"domainadd": func() (cli.Command, error) {
|
"domainadd": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.DomainAddCommand{Meta: meta}, nil
|
return &CmdDomainAdd{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"domaindel": func() (cli.Command, error) {
|
"domaindel": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.DomainDelCommand{Meta: meta}, nil
|
return &CmdDomainDel{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"domaindisable": func() (cli.Command, error) {
|
"domaindisable": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.DomainDisableCommand{Meta: meta}, nil
|
return &CmdDomainDisable{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"domainenable": func() (cli.Command, error) {
|
"domainenable": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.DomainEnableCommand{Meta: meta}, nil
|
return &CmdDomainEnable{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"aliasdomains": func() (cli.Command, error) {
|
"aliasdomains": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.AliasDomainsCommand{Meta: meta}, nil
|
return &CmdAliasDomains{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"aliasdomainadd": func() (cli.Command, error) {
|
"aliasdomainadd": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.AliasDomainAddCommand{Meta: meta}, nil
|
return &CmdAliasDomainAdd{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"aliasdomaindel": func() (cli.Command, error) {
|
"aliasdomaindel": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.AliasDomainDelCommand{Meta: meta}, nil
|
return &CmdAliasDomainDel{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"users": func() (cli.Command, error) {
|
"users": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.UsersCommand{Meta: meta}, nil
|
return &CmdUsers{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"useradd": func() (cli.Command, error) {
|
"useradd": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.UserAddCommand{Meta: meta}, nil
|
return &CmdUserAdd{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"userdel": func() (cli.Command, error) {
|
"userdel": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.UserDelCommand{Meta: meta}, nil
|
return &CmdUserDel{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"userpasswd": func() (cli.Command, error) {
|
"userpasswd": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.UserPasswdCommand{Meta: meta}, nil
|
return &CmdUserPasswd{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"usercheckpw": func() (cli.Command, error) {
|
"usercheckpw": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.UserCheckPwCommand{Meta: meta}, nil
|
return &CmdUserCheckPw{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"aliasusers": func() (cli.Command, error) {
|
"aliasusers": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.AliasUsersCommand{Meta: meta}, nil
|
return &CmdAliasUsers{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"aliasuseradd": func() (cli.Command, error) {
|
"aliasuseradd": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.AliasUserAddCommand{Meta: meta}, nil
|
return &CmdAliasUserAdd{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"aliasusermod": func() (cli.Command, error) {
|
"aliasusermod": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.AliasUserModCommand{Meta: meta}, nil
|
return &CmdAliasUserMod{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"aliasuserdel": func() (cli.Command, error) {
|
"aliasuserdel": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.AliasUserDelCommand{Meta: meta}, nil
|
return &CmdAliasUserDel{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"catchall": func() (cli.Command, error) {
|
"catchall": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.CatchAllCommand{Meta: meta}, nil
|
return &CmdCatchAll{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"catchallset": func() (cli.Command, error) {
|
"catchallset": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.CatchAllSetCommand{Meta: meta}, nil
|
return &CmdCatchAllSet{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"catchallunset": func() (cli.Command, error) {
|
"catchallunset": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.CatchAllUnsetCommand{Meta: meta}, nil
|
return &CmdCatchAllUnset{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
"commit": func() (cli.Command, error) {
|
"commit": func() (cli.Command, error) {
|
||||||
meta.SubCmdName = c.Subcommand()
|
meta.SubCmdName = c.Subcommand()
|
||||||
return &command.CommitCommand{Meta: meta}, nil
|
return &CmdCommit{Meta: meta}, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,3 +145,17 @@ func main() {
|
|||||||
|
|
||||||
os.Exit(exitCode)
|
os.Exit(exitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// noCommitFlag returns true if `pargs` has "-n" flag.
|
||||||
|
// `pargs` is overwrites with non-flag arguments.
|
||||||
|
func noCommitFlag(pargs *[]string) (bool, error) {
|
||||||
|
nFlag := false
|
||||||
|
|
||||||
|
flagSet := flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
|
flagSet.SetOutput(&bytes.Buffer{})
|
||||||
|
flagSet.BoolVar(&nFlag, "n", nFlag, "")
|
||||||
|
err := flagSet.Parse(*pargs)
|
||||||
|
*pargs = flagSet.Args()
|
||||||
|
|
||||||
|
return nFlag, err
|
||||||
|
}
|
||||||
20
cmd/meta.go
Normal file
20
cmd/meta.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/mitchellh/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Meta contains options to execute a command.
|
||||||
|
type Meta struct {
|
||||||
|
UI *cli.BasicUi
|
||||||
|
CmdName string
|
||||||
|
SubCmdName string
|
||||||
|
Version string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Errorf prints the error to ErrorWriter with the prefix string.
|
||||||
|
func (m Meta) Errorf(format string, v ...interface{}) {
|
||||||
|
fmt.Fprintf(m.UI.ErrorWriter, "[ERR] "+format, v...)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user