-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refacto : move main command in commands/base.go
- Loading branch information
Showing
6 changed files
with
57 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"scan2epub/utils" | ||
|
||
cli "github.com/urfave/cli/v2" | ||
) | ||
|
||
var MainFlags = []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: "output", | ||
Aliases: []string{"o"}, | ||
Usage: "output directory", | ||
Action: func(c *cli.Context, value string) error { | ||
if value == "" { | ||
return fmt.Errorf("Output directory is empty") | ||
} | ||
|
||
os.Unsetenv("EPUB_DIR") | ||
os.Setenv("EPUB_DIR", value) | ||
|
||
return nil | ||
}, | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "silent", | ||
Aliases: []string{"s"}, | ||
Usage: "disable printing log to stdout", | ||
Action: func(c *cli.Context, value bool) error { | ||
log, err := utils.GetLog() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.SetSilent(value) | ||
|
||
return nil | ||
}, | ||
}, | ||
} | ||
|
||
func MainAction(c *cli.Context) error { | ||
return fmt.Errorf("No command specified") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters