mozhi/cmd/imgtxt.go

32 lines
733 B
Go
Raw Normal View History

2023-07-03 17:46:58 +05:30
package cmd
import (
"codeberg.org/aryak/simplytranslate/utils"
"fmt"
2023-07-22 19:54:15 +05:30
"github.com/spf13/cobra"
2023-07-03 17:46:58 +05:30
)
var file string
var imgtxtCmd = &cobra.Command{
Use: "imgtxt",
Short: "Image -> Text.",
Long: `Convert given image (filename) to text using gosseract.`,
Run: func(cmd *cobra.Command, args []string) {
text, err := utils.ImgTxt(file)
if err != nil {
fmt.Println("Failed to convert image to text")
} else {
fmt.Println(text)
}
2023-07-03 17:46:58 +05:30
},
}
func init() {
rootCmd.AddCommand(imgtxtCmd)
imgtxtCmd.Flags().StringVarP(&file, "file", "f", "", "The query SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_query environment variable.")
langlist = imgtxtCmd.Flag("file").Value.String()
}