Add lua meta to be used with luals and dumped via cook -m
This commit is contained in:
16
main.go
16
main.go
@@ -4,6 +4,7 @@ import (
|
||||
_ "embed"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -64,6 +65,20 @@ Features:
|
||||
CreateExampleConfig()
|
||||
return
|
||||
}
|
||||
metaFlag, _ := cmd.Flags().GetBool("meta")
|
||||
if metaFlag {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
mainLogger.Error("Failed to get current directory: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
metaPath := filepath.Join(cwd, "meta.lua")
|
||||
if err := processor.GenerateMetaFile(metaPath); err != nil {
|
||||
mainLogger.Error("Failed to generate meta.lua: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return
|
||||
}
|
||||
if len(args) == 0 {
|
||||
cmd.Usage()
|
||||
return
|
||||
@@ -81,6 +96,7 @@ Features:
|
||||
rootCmd.Flags().Bool("json", false, "Enable JSON mode for processing JSON files")
|
||||
rootCmd.Flags().BoolP("conv", "c", false, "Convert YAML files to TOML format")
|
||||
rootCmd.Flags().BoolP("example", "e", false, "Generate example_cook.toml and exit")
|
||||
rootCmd.Flags().BoolP("meta", "m", false, "Generate meta.lua file for LuaLS autocomplete and exit")
|
||||
|
||||
// Set up examples in the help text
|
||||
rootCmd.SetUsageTemplate(`Usage:{{if .Runnable}}
|
||||
|
||||
Reference in New Issue
Block a user