ide_plugin

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IdePlugin = plugin.Builder().
	PostGenerationFeature().
	WithName("Open In IDE").
	WithDescription("Open the generated project in The Selected IDE").
	WithPostGenerationAction(func(ctx plugin.PostGenerationContext) error {
		hasVSCode := plugin.HasExec("code")()
		hasGoLand := plugin.HasExec("goland.sh")()

		line := strconv.FormatInt(int64(ctx.EntryPoint.Line), 10)

		openInVSCode := plugin.CommandAction("code", ".", "-r", "-g", ctx.EntryPoint.Path+":"+line)
		openInGoLand := plugin.CommandAction("goland.sh", "--line", line, ctx.EntryPoint.Path)

		if hasVSCode && !hasGoLand {
			return plugin.ConfirmAndThenActions("Open VSCode", openInVSCode)()
		} else if !hasVSCode && hasGoLand {
			return plugin.ConfirmAndThenActions("Open GoLand", openInGoLand)()
		} else if hasVSCode && hasGoLand {
			prompt := promptui.Select{
				Label: "Open project in",
				Items: []string{"VSCode", "GoLand"},
			}
			_, value, err := prompt.Run()
			if err != nil {
				return err
			}
			if value == "VSCode" {
				return openInVSCode()
			} else if value == "GoLand" {
				return openInGoLand()
			} else {
				return errors.New("invalid IDE Selected")
			}
		}
		return errors.New("no IDE Found, but the filter returned true. This is probably a bug in go-start")
	}).
	WithAvailabilityFilter(plugin.HasExec("code").Or(plugin.HasExec("goland.sh"))).
	AddFeature().
	Build()

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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