diff --git a/cmd/mailfull/command/aliasdomainadd.go b/cmd/mailfull/command/aliasdomainadd.go index 41d1222..2eb90d5 100644 --- a/cmd/mailfull/command/aliasdomainadd.go +++ b/cmd/mailfull/command/aliasdomainadd.go @@ -20,7 +20,7 @@ func (c *AliasDomainAddCommand) Synopsis() string { func (c *AliasDomainAddCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s domain target + %s %s [-n] domain target Description: %s @@ -30,6 +30,10 @@ Required Args: The domain name that you want to create. target The target domain name. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -39,6 +43,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *AliasDomainAddCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 2 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -64,6 +74,10 @@ func (c *AliasDomainAddCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/aliasdomaindel.go b/cmd/mailfull/command/aliasdomaindel.go index a16411c..1310f93 100644 --- a/cmd/mailfull/command/aliasdomaindel.go +++ b/cmd/mailfull/command/aliasdomaindel.go @@ -20,7 +20,7 @@ func (c *AliasDomainDelCommand) Synopsis() string { func (c *AliasDomainDelCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s domain + %s %s [-n] domain Description: %s @@ -28,6 +28,10 @@ Description: Required Args: domain The domain name that you want to delete. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -37,6 +41,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *AliasDomainDelCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -55,6 +65,10 @@ func (c *AliasDomainDelCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/aliasuseradd.go b/cmd/mailfull/command/aliasuseradd.go index 815a01a..9d6ee93 100644 --- a/cmd/mailfull/command/aliasuseradd.go +++ b/cmd/mailfull/command/aliasuseradd.go @@ -21,7 +21,7 @@ func (c *AliasUserAddCommand) Synopsis() string { func (c *AliasUserAddCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s address target [target...] + %s %s [-n] address target [target...] Description: %s @@ -31,6 +31,10 @@ Required Args: The email address that you want to create. target Target email addresses. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -40,6 +44,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *AliasUserAddCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) < 2 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -73,6 +83,10 @@ func (c *AliasUserAddCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/aliasuserdel.go b/cmd/mailfull/command/aliasuserdel.go index ea519c2..0eb5d12 100644 --- a/cmd/mailfull/command/aliasuserdel.go +++ b/cmd/mailfull/command/aliasuserdel.go @@ -21,7 +21,7 @@ func (c *AliasUserDelCommand) Synopsis() string { func (c *AliasUserDelCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s address + %s %s [-n] address Description: %s @@ -29,6 +29,10 @@ Description: Required Args: address The email address that you want to delete. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -38,6 +42,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *AliasUserDelCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -63,6 +73,10 @@ func (c *AliasUserDelCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/aliasusermod.go b/cmd/mailfull/command/aliasusermod.go index 16763fe..459cd67 100644 --- a/cmd/mailfull/command/aliasusermod.go +++ b/cmd/mailfull/command/aliasusermod.go @@ -21,7 +21,7 @@ func (c *AliasUserModCommand) Synopsis() string { func (c *AliasUserModCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s address target [target...] + %s %s [-n] address target [target...] Description: %s @@ -31,6 +31,10 @@ Required Args: The email address that you want to modify. target Target email addresses. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -40,6 +44,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *AliasUserModCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) < 2 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -82,6 +92,10 @@ func (c *AliasUserModCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/catchallset.go b/cmd/mailfull/command/catchallset.go index c7fa893..24acd67 100644 --- a/cmd/mailfull/command/catchallset.go +++ b/cmd/mailfull/command/catchallset.go @@ -20,7 +20,7 @@ func (c *CatchAllSetCommand) Synopsis() string { func (c *CatchAllSetCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s domain user + %s %s [-n] domain user Description: %s @@ -30,6 +30,10 @@ Required Args: The domain name. user The user name that you want to set as catchall user. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -39,6 +43,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *CatchAllSetCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 2 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -64,6 +74,10 @@ func (c *CatchAllSetCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/catchallunset.go b/cmd/mailfull/command/catchallunset.go index bf4164a..a6f3fe9 100644 --- a/cmd/mailfull/command/catchallunset.go +++ b/cmd/mailfull/command/catchallunset.go @@ -20,7 +20,7 @@ func (c *CatchAllUnsetCommand) Synopsis() string { func (c *CatchAllUnsetCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s domain + %s %s [-n] domain Description: %s @@ -28,6 +28,10 @@ Description: Required Args: domain The domain name. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -37,6 +41,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *CatchAllUnsetCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -55,6 +65,10 @@ func (c *CatchAllUnsetCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/domainadd.go b/cmd/mailfull/command/domainadd.go index 6e04fb2..1983d30 100644 --- a/cmd/mailfull/command/domainadd.go +++ b/cmd/mailfull/command/domainadd.go @@ -20,7 +20,7 @@ func (c *DomainAddCommand) Synopsis() string { func (c *DomainAddCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s domain + %s %s [-n] domain Description: %s @@ -28,6 +28,10 @@ Description: Required Args: domain The domain name that you want to create. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -37,6 +41,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *DomainAddCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -72,6 +82,10 @@ func (c *DomainAddCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/domaindel.go b/cmd/mailfull/command/domaindel.go index e7dcee7..a8b9be9 100644 --- a/cmd/mailfull/command/domaindel.go +++ b/cmd/mailfull/command/domaindel.go @@ -20,7 +20,7 @@ func (c *DomainDelCommand) Synopsis() string { func (c *DomainDelCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s domain + %s %s [-n] domain Description: %s @@ -28,6 +28,10 @@ Description: Required Args: domain The domain name that you want to delete. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -37,6 +41,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *DomainDelCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -55,6 +65,10 @@ func (c *DomainDelCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/domaindisable.go b/cmd/mailfull/command/domaindisable.go index 98e69f6..c254c77 100644 --- a/cmd/mailfull/command/domaindisable.go +++ b/cmd/mailfull/command/domaindisable.go @@ -20,7 +20,7 @@ func (c *DomainDisableCommand) Synopsis() string { func (c *DomainDisableCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s domain + %s %s [-n] domain Description: %s @@ -28,6 +28,10 @@ Description: Required Args: domain The domain name that you want to disable. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -37,6 +41,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *DomainDisableCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -67,6 +77,10 @@ func (c *DomainDisableCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/domainenable.go b/cmd/mailfull/command/domainenable.go index 25e782d..6fff76d 100644 --- a/cmd/mailfull/command/domainenable.go +++ b/cmd/mailfull/command/domainenable.go @@ -20,7 +20,7 @@ func (c *DomainEnableCommand) Synopsis() string { func (c *DomainEnableCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s domain + %s %s [-n] domain Description: %s @@ -28,6 +28,10 @@ Description: Required Args: domain The domain name that you want to enable. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -37,6 +41,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *DomainEnableCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -67,6 +77,10 @@ func (c *DomainEnableCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/useradd.go b/cmd/mailfull/command/useradd.go index 8f3bd1f..943f493 100644 --- a/cmd/mailfull/command/useradd.go +++ b/cmd/mailfull/command/useradd.go @@ -21,7 +21,7 @@ func (c *UserAddCommand) Synopsis() string { func (c *UserAddCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s address + %s %s [-n] address Description: %s @@ -29,6 +29,10 @@ Description: Required Args: address The email address that you want to create. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -38,6 +42,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *UserAddCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -70,6 +80,10 @@ func (c *UserAddCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/usercheckpw.go b/cmd/mailfull/command/usercheckpw.go index 66d93af..4ef780a 100644 --- a/cmd/mailfull/command/usercheckpw.go +++ b/cmd/mailfull/command/usercheckpw.go @@ -34,7 +34,7 @@ Required Args: Optional Args: password Specify the password instead of your typing. - This option is not recommended because the password will be visible in your shell history. + This option is NOT recommended because the password will be visible in your shell history. `, c.CmdName, c.SubCmdName, c.Synopsis()) diff --git a/cmd/mailfull/command/userdel.go b/cmd/mailfull/command/userdel.go index 9e2d2b4..858b8ff 100644 --- a/cmd/mailfull/command/userdel.go +++ b/cmd/mailfull/command/userdel.go @@ -21,7 +21,7 @@ func (c *UserDelCommand) Synopsis() string { func (c *UserDelCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s address + %s %s [-n] address Description: %s @@ -29,6 +29,10 @@ Description: Required Args: address The email address that you want to delete. + +Optional Args: + -n + Don't update databases. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -38,6 +42,12 @@ Required Args: // Run runs the command and returns the exit status. func (c *UserDelCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -69,6 +79,10 @@ func (c *UserDelCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) diff --git a/cmd/mailfull/command/userpasswd.go b/cmd/mailfull/command/userpasswd.go index ea568d8..bbd724c 100644 --- a/cmd/mailfull/command/userpasswd.go +++ b/cmd/mailfull/command/userpasswd.go @@ -22,7 +22,7 @@ func (c *UserPasswdCommand) Synopsis() string { func (c *UserPasswdCommand) Help() string { txt := fmt.Sprintf(` Usage: - %s %s address [password] + %s %s [-n] address [password] Description: %s @@ -32,9 +32,11 @@ Required Args: The email address that you want to update the password. Optional Args: + -n + Don't update databases. password Specify the password instead of your typing. - This option is not recommended because the password will be visible in your shell history. + This option is NOT recommended because the password will be visible in your shell history. `, c.CmdName, c.SubCmdName, c.Synopsis()) @@ -44,6 +46,12 @@ Optional Args: // Run runs the command and returns the exit status. func (c *UserPasswdCommand) Run(args []string) int { + noCommit, err := noCommitFlag(&args) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) + return 1 + } + if len(args) != 1 && len(args) != 2 { fmt.Fprintf(c.UI.ErrorWriter, "%v\n", c.Help()) return 1 @@ -115,6 +123,10 @@ func (c *UserPasswdCommand) Run(args []string) int { return 1 } + if noCommit { + return 0 + } + mailData, err := repo.MailData() if err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)