func main()

in cmd/kepify/main.go [39:102]


func main() {
	dirPath := flag.String("dir", "keps", "root directory for the KEPs")
	filePath := flag.String("output", "keps.json", "output json file")

	flag.Usage = Usage
	flag.Parse()

	if *dirPath == "" {
		fmt.Fprintf(os.Stderr, "please specify the root directory for KEPs using '--dir'\n")
		os.Exit(1)
	}

	if _, err := os.Stat(*dirPath); os.IsNotExist(err) {
		fmt.Printf("directory does not exist : %s", *dirPath)
		os.Exit(1)
	}

	if *filePath == "" {
		fmt.Fprintf(os.Stderr, "please specify the file path for the output json using '--output'\n")
		os.Exit(1)
	}

	// Find all of the KEPs
	files, err := findMarkdownFiles(dirPath)
	if err != nil {
		fmt.Fprintf(os.Stderr, "unable to find markdown files: %v\n", err)
		os.Exit(1)
	}

	if len(files) == 0 {
		fmt.Fprintf(os.Stderr, "did not find any KEPs\n")
		os.Exit(1)
	}

	fetcher := api.DefaultGroupFetcher()

	groups, err := fetcher.FetchGroups()
	if err != nil {
		fmt.Fprintf(os.Stderr, "unable to fetch groups: %v", err)
		os.Exit(1)
	}

	prrApprovers, err := fetcher.FetchPRRApprovers()
	if err != nil {
		fmt.Fprintf(os.Stderr, "unable to fetch PRR approvers: %v", err)
		os.Exit(1)
	}

	kepHandler := &api.KEPHandler{Groups: groups, PRRApprovers: prrApprovers}

	// Parse the files
	proposals, err := parseFiles(kepHandler, files)
	if err != nil {
		fmt.Fprintf(os.Stderr, "error parsing files: %q\n", err)
		os.Exit(1)
	}

	// Generate the json output
	err = printJSONOutput(*filePath, proposals)
	if err != nil {
		fmt.Fprintf(os.Stderr, "could not open file: %v\n", err)
		os.Exit(1)
	}
}