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 ) {
2023-08-15 14:55:49 +05:30
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 ( )
}