mirror of
https://github.com/bestnite/bilinovel-downloader.git
synced 2025-10-26 09:11:01 +00:00
start
This commit is contained in:
36
cmd/package.go
Normal file
36
cmd/package.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bilinovel-downloader/utils"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type packArgs struct {
|
||||
DirPath string `validate:"required"`
|
||||
}
|
||||
|
||||
var (
|
||||
pArgs packArgs
|
||||
)
|
||||
|
||||
var packCmd = &cobra.Command{
|
||||
Use: "pack",
|
||||
Short: "pack a epub file from directory",
|
||||
Long: "pack a epub file from directory",
|
||||
RunE: runPackage,
|
||||
}
|
||||
|
||||
func init() {
|
||||
packCmd.Flags().StringVarP(&pArgs.DirPath, "dir-path", "d", "", "directory path")
|
||||
RootCmd.AddCommand(packCmd)
|
||||
}
|
||||
|
||||
func runPackage(cmd *cobra.Command, args []string) error {
|
||||
err := utils.CreateEpub(pArgs.DirPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create epub: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user