5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 05:50:08 +08:00
wails/v3/internal/plugins/plugins.go
2023-03-19 09:13:05 +11:00

37 lines
688 B
Go

package plugins
import (
"embed"
"fmt"
"io/fs"
"os"
"path/filepath"
"github.com/wailsapp/wails/v3/internal/flags"
"github.com/leaanthony/gosod"
"github.com/samber/lo"
)
//go:embed template
var pluginTemplate embed.FS
type TemplateOptions struct {
*flags.PluginInit
}
func Install(options *flags.PluginInit) error {
if options.OutputDir == "." || options.OutputDir == "" {
options.OutputDir = filepath.Join(lo.Must(os.Getwd()), options.Name)
}
fmt.Printf("Creating plugin '%s' into '%s'\n", options.Name, options.OutputDir)
tfs, err := fs.Sub(pluginTemplate, "template")
if err != nil {
return err
}
return gosod.New(tfs).Extract(options.OutputDir, options)
}