<commit_before>package main

import (
	"flag"

	"github.com/resumic/schema/cmd/resumic/validate"
)

func main() {
	var doc string
	flag.StringVar(&doc, "doc", "../../examples/invalid/invalid_email.json", "Example file")
	flag.Parse()
	validate.ValidateJSON(doc)
}
<commit_msg>Add subcommand for generating schema.json file<commit_after>package main

import (
	"encoding/json"
	"flag"
	"fmt"
	"log"
	"os"

	"github.com/erbesharat/schema/schema"
	"github.com/resumic/schema/cmd/resumic/validate"
)

func main() {
	var doc string
	var schemaFile string
	flag.StringVar(&doc, "doc", "../../examples/invalid/invalid_email.json", "Example file")
	flag.StringVar(&schemaFile, "schema", "./schema.json", "Generate JSON Schema")
	flag.Parse()

	// Verify that a subcommand has been provided
	if len(flag.Args()) < 1 {
		fmt.Println("subcommand is required")
		os.Exit(1)
	}
	switch flag.Args()[0] {
	case "validate":
		validate.ValidateJSON(doc)
	case "schema":
		schema, err := schema.GetSchema()
		if err != nil {
			log.Fatalf("Couldn't get the schema struct: %s", err)
		}
		json, err := json.Marshal(schema)
		if err != nil {
			log.Fatal("couldn't parse the schema")
		}
		file, err := os.Create(schemaFile)
		defer file.Close()
		if err != nil {
			log.Fatal("couldn't create the schema file")
		}
		_, err = file.Write(json)
		if err != nil {
			log.Fatal("couldn't write the schema content to given the schema file")
		}
		log.Printf("Schema file created successfully: %s", file.Name())
	default:
		log.Fatalf("Unsupported subcommands. Please check --help for commands list")
	}
}

{'fraction_non_alphanumeric': 0.1555977229601518, 'fraction_numerical': 0.0018975332068311196, 'mean_word_length': 3.959247648902821, 'pattern_counts': {'":': 2, '<': 4, '<?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': '5352582', 'n_tokens_mistral': 583, 'n_tokens_neox': 551, 'n_words': 139}