<commit_before>// main.go
package main

import (
	"github.com/jessevdk/go-flags"
	"os"
	"log"
	"strings"
	"bufio"
	"encoding/base64"
	"github.com/beplus/mobile-icons-generator/app/helper/image-helper"
	"fmt"
)

var args struct {
	Filename string `short:"n" long:"file" description:"filename to make assets"`
}

func main() {
	_, err := flags.ParseArgs(&args, os.Args)
	if err != nil {
		log.Fatal("Parsing flags error")
	}

	if args.Filename == "" {
		log.Fatal("No file set use -n or --file to set it")
	}

	// todo windows \
	s := strings.Split(args.Filename, "/")
	filename := s[len(s)-1]
	// prepare json body

	filenameArray := strings.Split(filename, ".")
	name, extension := filenameArray[0], filenameArray[1]

	myImage, err := image_helper.NewMyImageFromBase64(getImageBase64(args.Filename), name, extension)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("Processing icons... It could few seconds...")

	_, err = myImage.Upload("icons", "local", "", "folder")
	if err != nil {
		log.Println(err)
	} else {
		fmt.Println("Icons saved to folder 'icons'.")
	}
}

func getImageBase64(filename string) string {
	imgFile, err := os.Open(filename)
	if err != nil {
		log.Fatal("Open file fail")
	}
	defer imgFile.Close()

	// create a new buffer base on file size
	fInfo, _ := imgFile.Stat()
	var size int64 = fInfo.Size()
	buf := make([]byte, size)

	// read file content into buffer
	fReader := bufio.NewReader(imgFile)
	fReader.Read(buf)

	// convert the buffer bytes to base64 string - use buf.Bytes() for new image
	return base64.StdEncoding.EncodeToString(buf)
}<commit_msg>output message fix<commit_after>// main.go
package main

import (
	"github.com/jessevdk/go-flags"
	"os"
	"log"
	"strings"
	"bufio"
	"encoding/base64"
	"github.com/beplus/mobile-icons-generator/app/helper/image-helper"
	"fmt"
)

var args struct {
	Filename string `short:"n" long:"file" description:"filename to make assets"`
}

func main() {
	_, err := flags.ParseArgs(&args, os.Args)
	if err != nil {
		log.Fatal("Parsing flags error")
	}

	if args.Filename == "" {
		log.Fatal("No file set use -n or --file to set it")
	}

	// todo windows \
	s := strings.Split(args.Filename, "/")
	filename := s[len(s)-1]
	// prepare json body

	filenameArray := strings.Split(filename, ".")
	name, extension := filenameArray[0], filenameArray[1]

	myImage, err := image_helper.NewMyImageFromBase64(getImageBase64(args.Filename), name, extension)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("Processing icons... It could few seconds...")

	_, err = myImage.Upload("icons", "local", "", "folder")
	if err != nil {
		log.Println(err)
	} else {
		fmt.Println("Icons saved to folder 'AppIcon'.")
	}
}

func getImageBase64(filename string) string {
	imgFile, err := os.Open(filename)
	if err != nil {
		log.Fatal("Open file fail")
	}
	defer imgFile.Close()

	// create a new buffer base on file size
	fInfo, _ := imgFile.Stat()
	var size int64 = fInfo.Size()
	buf := make([]byte, size)

	// read file content into buffer
	fReader := bufio.NewReader(imgFile)
	fReader.Read(buf)

	// convert the buffer bytes to base64 string - use buf.Bytes() for new image
	return base64.StdEncoding.EncodeToString(buf)
}
{'fraction_non_alphanumeric': 0.15728216420257943, 'fraction_numerical': 0.0106951871657754, 'mean_word_length': 3.825493171471927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7328395', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1114, 'n_words': 292}