cmd

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: 19 Imported by: 0

Documentation

Overview

Copyright 2025 PRAS

Copyright 2025 PRAS

Index

Constants

This section is empty.

Variables

View Source
var CheckForUpdates = func() {
	const checkInterval = 24 * time.Hour

	cache, err := readUpdateCache()
	if err == nil {
		if lastCheckedStr, ok := cache["last_checked"].(string); ok {
			lastCheckedTime, err := timeParse(time.RFC3339, lastCheckedStr)
			if err == nil && timeSince(lastCheckedTime) < checkInterval {
				if latestHash, ok := cache["latest_hash"].(string); ok {
					isAvailable, currentHash := isUpdateAvailable(latestHash)
					if isAvailable {
						if latestTag, ok := cache["latest_tag"].(string); ok {
							printUpdateMessage(latestTag, latestHash, currentHash)
						}
					}
				}
				return
			}
		}
	}

	releaseJSON, err := fetchURL("https://api.github.com/repos/PRASSamin/prasmoid/releases/latest")
	if err != nil {
		return
	}

	var releaseData map[string]interface{}
	if err := jsonUnmarshal([]byte(releaseJSON), &releaseData); err != nil {
		return
	}

	sha256sums, err := getSha256Sums(releaseData["assets"])

	if err != nil {
		return
	}

	assetName := "prasmoid"
	if strings.Contains(internalAppMetaDataVersion, "-portable") {
		assetName = "prasmoid-portable"
	}

	latestHash := parseChecksums(sha256sums, assetName)
	latestTag := getLatestTag(releaseData)

	writeUpdateCache(latestTag, latestHash)

	isAvailable, currentHash := isUpdateAvailable(latestHash)
	if isAvailable {
		printUpdateMessage(latestTag, latestHash, currentHash)
	}
}
View Source
var ConfigRC types.Config

project wise prasmoid config

View Source
var GetCacheFilePath = func() string {
	dir, err := osUserCacheDir()
	if err != nil {
		dir = osTempDir()
	}
	return filepath.Join(dir, ".prasmoid")
}
View Source
var RootCmd = &cobra.Command{
	Use:   "prasmoid",
	Short: "Manage plasmoid projects",
	Long:  "CLI for building, packaging, and managing KDE plasmoid projects efficiently.",
	Run: func(cmd *cobra.Command, args []string) {
		if cmd.Flag("version").Changed {
			fmt.Println(internalAppMetaDataVersion)
			osExit(0)
		}

		if err := cmd.Help(); err != nil {
			logPrintf("Error displaying help: %v", err)
		}
	},
}

rootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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