mirror of
				https://github.com/bestnite/bilinovel-downloader.git
				synced 2025-10-31 10:50:35 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			645 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			645 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package cmd
 | |
| 
 | |
| import (
 | |
| 	"bilinovel-downloader/epub"
 | |
| 	"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 := epub.PackEpub(pArgs.DirPath)
 | |
| 	if err != nil {
 | |
| 		return fmt.Errorf("failed to create epub: %v", err)
 | |
| 	}
 | |
| 	return nil
 | |
| }
 |