preview

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Copyright 2025 PRAS

Index

Constants

This section is empty.

Variables

View Source
var PreviewCmd = &cobra.Command{
	Use:  "preview",
	Long: "Launch the plasmoid in preview mode for testing and development.",
	Run: func(cmd *cobra.Command, args []string) {
		if !utilsIsPackageInstalled("plasmoidviewer") {
			fmt.Println(color.RedString("preview command is disabled due to missing dependencies."))
			fmt.Println(color.BlueString("- Use `prasmoid fix` to install them."))
			return
		}
		if !utilsIsValidPlasmoid() {
			fmt.Println(color.RedString("Current directory is not a valid plasmoid."))
			return
		}
		watch, _ := cmd.Flags().GetBool("watch")

		if !utilsIsLinked() {
			confirmPrompt := &survey.Confirm{
				Message: "Plasmoid is not linked. Do you want to link it first?",
				Default: true,
			}
			if err := surveyAskOne(confirmPrompt, &confirmLink); err != nil {
				return
			}

			if confirmLink {
				dest, err := utilsGetDevDest()
				if err != nil {
					fmt.Println(color.RedString(err.Error()))
					return
				}
				if err := linkLinkPlasmoid(dest); err != nil {
					fmt.Println(color.RedString("Failed to link plasmoid: %v", err))
					return
				}
			} else {
				fmt.Println("Operation cancelled.")
				return
			}
		}

		if err := previewPlasmoid(watch); err != nil {
			fmt.Println(color.RedString("Failed to preview plasmoid: %v", err))
			return
		}
	},
}

PreviewCmd represents the preview command

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