vue

package
v0.0.0-...-ae29a83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddVueComponent = command.InlineHandler[*VueComponentConfig](func(c *cli.Context, config *VueComponentConfig) error {
	filename := strcase.ToCamel(config.Name)
	kebabName := strcase.ToKebab(config.Name)
	outDir := config.OutDir

	if config.Isolated {
		filename = "index"
		outDir = path.Join(config.OutDir, kebabName)
	}

	b := new(bytes.Buffer)
	if err := task.NewSequentialScheduler().
		AddTask(task.NewReadFromProviderTask(provider.NewEmbedFileProvider("templates/vue/vue_component.go.tmpl"), b)).
		AddTask(task.NewTemplateRenderTask("vue_component", nil, b, b)).
		AddTask(task.NewWriteFileToDiskTask(filename, ".vue", b, task.WithFolder(outDir))).
		Run(); err != nil {
		return err
	}
	return nil
})
View Source
var AddVueDirective = command.InlineHandler[*VueDirectiveConfig](func(c *cli.Context, config *VueDirectiveConfig) error {
	filename := config.Name
	camelName := strcase.ToCamel(filename)
	outDir := config.OutDir

	if config.Isolated {
		outDir = path.Join(config.OutDir, filename)
		filename = "index"
	}

	b := new(bytes.Buffer)
	if err := task.NewSequentialScheduler().
		AddTask(task.NewReadFromProviderTask(provider.NewEmbedFileProvider("templates/vue/vue_directive.go.tmpl"), b)).
		AddTask(task.NewTemplateRenderTask("vue_directive", map[string]string{
			"name": camelName,
		}, b, b)).
		AddTask(task.NewWriteFileToDiskTask(filename, ".ts", b, task.WithFolder(outDir))).
		Run(); err != nil {
		return err
	}
	return nil
})
View Source
var CommandSet = &cli.Command{
	Name:    "vue",
	Aliases: []string{"v"},
	Usage:   "vue 工具套件",
	Subcommands: []*cli.Command{
		VueUseStoreCmd,
		VueComponentCmd,
		VueDirectiveCmd,
	},
}
View Source
var UseVueStore = command.InlineHandler[*VueUseStoreConfig](func(c *cli.Context, config *VueUseStoreConfig) error {
	name := strcase.ToCamel(config.Name)
	storeKey := strcase.ToKebab(config.Name)
	filename := fmt.Sprintf("use%sStore", name)

	b := new(bytes.Buffer)
	if err := task.NewSequentialScheduler().
		AddTask(task.NewReadFromProviderTask(provider.NewEmbedFileProvider("templates/vue/vue_use_store.go.tmpl"), b)).
		AddTask(task.NewTemplateRenderTask("vue_use_store", map[string]string{"storeKey": storeKey, "name": name}, b, b)).
		AddTask(task.NewWriteFileToDiskTask(filename, ".ts", b, task.WithFolder(config.OutDir))).
		Run(); err != nil {
		return err
	}
	return nil
})
View Source
var VueComponentCmd = command.NewCommand("component", "add vue component",
	new(VueComponentConfig),
	command.WithAlias([]string{"c"}),
).AddHandler(
	AddVueComponent,
).Create()
View Source
var VueDirectiveCmd = command.NewCommand("directive", "add vue directive",
	new(VueDirectiveConfig),
	command.WithAlias([]string{"d"}),
).AddHandler(
	AddVueDirective,
).Create()
View Source
var VueUseStoreCmd = command.NewCommand("store", "add vue pinia store",
	new(VueUseStoreConfig),
	command.WithAlias([]string{"s"}),
).AddHandler(
	UseVueStore,
).Create()

Functions

This section is empty.

Types

type VueComponentConfig

type VueComponentConfig struct {
	Isolated bool   `flag:"isolated" alias:"i" usage:"generate files in a folder"`
	OutDir   string `flag:"output" alias:"o" usage:"destination directory"`
	Name     string `arg:"0" alias:"COMPONENT_NAME" validate:"required,identifier"`
}

type VueDirectiveConfig

type VueDirectiveConfig struct {
	Isolated bool   `flag:"isolated" alias:"i" usage:"generate files in a folder"`
	OutDir   string `flag:"output" alias:"o" usage:"destination directory"`
	Name     string `arg:"0" alias:"COMPONENT_NAME" validate:"required,identifier"`
}

type VueUseStoreConfig

type VueUseStoreConfig struct {
	OutDir string `flag:"output" alias:"o" usage:"destination directory"`
	Name   string `arg:"0" alias:"MODULE_NAME" validate:"required,identifier"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL