mirror of
https://github.com/directorz/mailfull-go.git
synced 2025-12-23 12:37:09 +00:00
Add a option to subcommands #7
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user