source

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   CommandString,
	Short: "source a script or snippet",
	Long:  `if it runs with clog cmd then it will source with eval "$(clog Source cmd)"`,
	Run: func(cmd *cobra.Command, args []string) {
		cmdString := strings.Join(args, " ")

		slog.Debug("searching snippets:  " + cmdString)
		srcCmd, err := FindSnippet(cmd.Root(), args)
		if err == nil {

			switch srcCmd.Annotations["is-a"] {
			case "snippet":
				fmt.Println(srcCmd.Annotations["script"])
				os.Exit(0)
			case "script":
				fmt.Println(srcCmd.Annotations["file-path"])
				os.Exit(0)
			default:
				slog.Error(fmt.Sprintf("clog Source (%s) neither snippet nor script", cmdString))
				os.Exit(1)
			}
		}
		slog.Error(fmt.Sprintf("clog Source (%s) %s", cmdString, err.Error()))
		os.Exit(1)
	},
}

Command define the cobra settings for this command

View Source
var CommandString = "Source"
View Source
var JustCrayon bool = false
View Source
var SnippetsTree bool = false

Functions

func FindSnippet

func FindSnippet(rootCmd *cobra.Command, args []string) (*cobra.Command, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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