INNER CODE UNIT · Go

main

kopecmaciej/vi-mongo · scripts/migrate_keybindings/main.go:24

func main() {
	jsonPath := flag.String("json", defaultJSONPath(), "path to keybindings.json")
	flag.Parse()

	yamlPath := (*jsonPath)[:len(*jsonPath)-len(filepath.Ext(*jsonPath))] + ".yaml"

	if _, err := os.Stat(*jsonPath); os.IsNotExist(err) {
		fmt.Fprintf(os.Stderr, "Error: %s not found\n", *jsonPath)
		os.Exit(1)
	}

	if _, err := os.Stat(yamlPath); err == nil {
		fmt.Fprintf(os.Stderr, "Error: %s already exists, remove it first if you want to re-migrate\n", yamlPath)
		os.Exit(1)
	}

	data, err := os.ReadFile(*jsonPath)
	if err != nil {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…