cmd

package
v0.6.10-rc.3 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 33 Imported by: 1

Documentation

Index

Constants

View Source
const RootCustomHelp = `` /* 1261-byte string literal not displayed */

Variables

View Source
var (
	UpdateCheckFlag   bool
	UpdateVersionFlag string

	UpdateStarted   bool
	UpdateErrored   bool
	UpdateChecked   bool
	UpdateAvailable *ProgramVersion
	UpdateData      []interface{}
)
View Source
var BashCompletionCmd = &cobra.Command{
	Use:   "bash",
	Short: "Generate Bash completions",
	Long:  BashCompletionLong,
	Run: func(cmd *cobra.Command, args []string) {
		RootCmd.GenBashCompletionV2(os.Stdout, false)
	},
}
View Source
var BashCompletionLong = `` /* 214-byte string literal not displayed */
View Source
var ChatCmd = &cobra.Command{

	Use: "chat [args]",

	Short: "co-create with AI (alpha)",

	Long: chatLong,

	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		glob := toComplete + "*"
		matches, _ := filepath.Glob(glob)
		return matches, cobra.ShellCompDirectiveDefault
	},

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		err = ChatRun(args)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var CompletionCmd = &cobra.Command{
	Use:     "completion",
	Aliases: []string{"completions"},
	Short:   "Generate completion helpers for popular terminals",
	Long:    "Generate completion helpers for popular terminals",
}
View Source
var (
	CompletionVanillaFlag bool
)
View Source
var CreateCmd = &cobra.Command{

	Use: "create <module path> [extra args]",

	Short: "starter kits or blueprints from any git repo",

	Long: createLong,

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		if 0 >= len(args) {
			fmt.Println("missing required argument: 'module'")
			cmd.Usage()
			os.Exit(1)
		}

		var module string

		if 0 < len(args) {

			module = args[0]

		}

		var extra []string

		if 1 < len(args) {

			extra = args[1:]

		}

		err = CreateRun(module, extra)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var DatamodelCmd = &cobra.Command{

	Use: "datamodel",

	Aliases: []string{
		"dm",
	},

	Short: "manage, diff, and migrate your data models",

	Long: datamodelLong,
}
View Source
var DefCmd = &cobra.Command{

	Use: "def",

	Short: "print consolidated CUE definitions",

	Long: defLong,

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		err = DefRun(args)
		if err != nil {

			fmt.Fprint(os.Stderr, err)
			os.Exit(1)
		}
	},
}
View Source
var EvalCmd = &cobra.Command{

	Use: "eval",

	Short: "evaluate and print CUE configuration",

	Long: evalLong,

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		err = EvalRun(args)
		if err != nil {

			fmt.Fprint(os.Stderr, err)
			os.Exit(1)
		}
	},
}
View Source
var ExportCmd = &cobra.Command{

	Use: "export",

	Short: "output data in a standard format",

	Long: exportLong,

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		err = ExportRun(args)
		if err != nil {

			fmt.Fprint(os.Stderr, err)
			os.Exit(1)
		}
	},
}
View Source
var FeedbackCmd = &cobra.Command{

	Use: "feedback <message>",

	Aliases: []string{
		"hi",
		"ask",
		"report",
	},

	Short: "open an issue or discussion on GitHub",

	Long: feedbackLong,

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		err = FeedbackRun(args)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var FishCompletionCmd = &cobra.Command{
	Use:   "fish",
	Short: "Generate Fish completions",
	Long:  "Generate Fish completions",

	Run: func(cmd *cobra.Command, args []string) {
		RootCmd.GenFishCompletion(os.Stdout, true)
	},
}
View Source
var FlowCmd = &cobra.Command{

	Use: "flow [cue files...] [@flow/name...] [+key=value]",

	Aliases: []string{
		"f",
	},

	Short: "run workflows and tasks powered by CUE",

	Long: flowLong,

	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		glob := toComplete + "*"
		matches, _ := filepath.Glob(glob)
		return matches, cobra.ShellCompDirectiveDefault
	},

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		err = FlowRun(args)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var FmtCmd = &cobra.Command{

	Use: "fmt [filepaths or globs]",

	Short: "format any code and manage the formatters",

	Long: fmtLong,

	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		glob := toComplete + "*"
		matches, _ := filepath.Glob(glob)
		return matches, cobra.ShellCompDirectiveDefault
	},

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		if 0 >= len(args) {
			fmt.Println("missing required argument: 'files'")
			cmd.Usage()
			os.Exit(1)
		}

		var files []string

		if 0 < len(args) {

			files = args[0:]

		}

		err = FmtRun(files)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var GenCmd = &cobra.Command{

	Use: "gen [files...]",

	Aliases: []string{
		"G",
	},

	Short: "CUE powered code generation",

	Long: genLong,

	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		glob := toComplete + "*"
		matches, _ := filepath.Glob(glob)
		return matches, cobra.ShellCompDirectiveDefault
	},

	Run: func(cmd *cobra.Command, args []string) {

		extra := " "

		if len(flags.GenFlags.Template) == 0 {
			extra = extra + "module"
		} else {
			extra = extra + "adhoc"
		}

		if flags.GenFlags.Watch || len(flags.GenFlags.WatchFull) > 0 || len(flags.GenFlags.WatchFull) > 0 {
			extra = extra + " watch"
		}

		ga.SendCommandPath(cmd.CommandPath() + extra)

		var err error

		err = GenRun(args)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var ModCmd = &cobra.Command{

	Use: "mod",

	Aliases: []string{
		"m",
	},

	Short: "CUE module dependency management",

	Long: modLong,

	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		var err error

		err = ModPersistentPreRun(args)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var PowerShellCompletionCmd = &cobra.Command{
	Use:     "power-shell",
	Aliases: []string{"windows", "win", "power", "ps"},
	Short:   "Generate PowerShell completions",
	Long:    "Generate PowerShell completions",

	Run: func(cmd *cobra.Command, args []string) {
		RootCmd.GenPowerShellCompletion(os.Stdout)
	},
}
View Source
var RootCmd = &cobra.Command{

	Use: "hof",

	Short: "The Higher Order Framework",

	Long: hofLong,

	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		var err error

		err = RootPersistentPreRun(args)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},

	PreRun: func(cmd *cobra.Command, args []string) {
		fmt.Println("root prerun")

		ga.SendCommandPath("root")

	},

	PersistentPostRun: func(cmd *cobra.Command, args []string) {
		var err error

		err = RootPersistentPostRun(args)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var RunCmd = &cobra.Command{

	Use: "run",

	Aliases: []string{
		"r",
	},

	Short: "Hof Line Script (HLS) is a successor to bash and python based scripting",

	Long: runLong,

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		err = RunRun(args)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var TuiCmd = &cobra.Command{

	Use: "tui",

	Short: "a terminal interface to Hof and CUE",

	Long: tuiLong,

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		err = TuiRun(args)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var UpdateCmd = &cobra.Command{

	Use: "update",

	Short: "update the hof tool",

	Long: UpdateLong,

	PreRun: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath("update")

	},

	Run: func(cmd *cobra.Command, args []string) {

		latest, err := CheckUpdate(true)
		if err != nil {
			fmt.Println(err)
			os.Exit(-1)
		}

		cur := ProgramVersion{Version: verinfo.Version}
		if latest.Version == cur.Version || (UpdateVersionFlag == "" && cur.Version == "vLocal") {
			return
		} else {
			if UpdateCheckFlag {
				PrintUpdateAvailable()
				return
			}
		}

		err = InstallUpdate()
		if err != nil {
			fmt.Println(err)
			os.Exit(-1)
		}
	},
}
View Source
var UpdateLong = `Print the build version for hof`
View Source
var VersionCmd = &cobra.Command{

	Use: "version",

	Aliases: []string{
		"ver",
	},

	Short: "print the version",

	Long: VersionLong,

	Run: func(cmd *cobra.Command, args []string) {

		configDir, _ := os.UserConfigDir()
		cacheDir, _ := os.UserCacheDir()

		err := container.InitClient()
		if err != nil {
			fmt.Println(err)
		}

		rt, err := container.GetVersion()
		if err != nil {
			fmt.Println(err)
		}

		fmt.Printf(
			versionMessage,
			verinfo.Version,
			verinfo.Commit,
			verinfo.BuildDate,
			verinfo.GoVersion,
			verinfo.CueVersion,
			verinfo.BuildOS,
			verinfo.BuildArch,
			filepath.Join(configDir, "hof"),
			filepath.Join(cacheDir, "hof"),
			rt,
		)
	},
}
View Source
var VersionLong = `Print the build version for hof`
View Source
var VetCmd = &cobra.Command{

	Use: "vet",

	Short: "validate data with CUE",

	Long: vetLong,

	Run: func(cmd *cobra.Command, args []string) {

		ga.SendCommandPath(cmd.CommandPath())

		var err error

		err = VetRun(args)
		if err != nil {

			fmt.Fprint(os.Stderr, err)
			os.Exit(1)
		}
	},
}
View Source
var ZshCompletionCmd = &cobra.Command{
	Use:   "zsh",
	Short: "Generate Zsh completions",
	Long:  "Generate Zsh completions",
	Run: func(cmd *cobra.Command, args []string) {
		RootCmd.GenZshCompletion(os.Stdout)
	},
}

Functions

func ChatRun added in v0.6.8

func ChatRun(args []string) (err error)

func CreateRun added in v0.5.0

func CreateRun(module string, extra []string) (err error)

func DefRun added in v0.5.0

func DefRun(args []string) (err error)

func EvalRun added in v0.5.0

func EvalRun(args []string) (err error)

func ExportRun added in v0.4.7

func ExportRun(args []string) (err error)

func FeedbackRun added in v0.5.1

func FeedbackRun(args []string) (err error)

func FlowRun added in v0.6.2

func FlowRun(args []string) (err error)

func FmtRun added in v0.5.0

func FmtRun(files []string) (err error)

func GenRun

func GenRun(args []string) (err error)

func InstallUpdate added in v0.4.6

func InstallUpdate() (err error)

func ModPersistentPreRun added in v0.4.8

func ModPersistentPreRun(args []string) (err error)

func PrintUpdateAvailable added in v0.4.4

func PrintUpdateAvailable()

func RootInit added in v0.5.1

func RootInit()

func RootPersistentPostRun added in v0.4.6

func RootPersistentPostRun(args []string) (err error)

func RootPersistentPreRun

func RootPersistentPreRun(args []string) (err error)

func RunErr added in v0.5.7

func RunErr() error

func RunExit added in v0.5.7

func RunExit()

func RunInt added in v0.5.7

func RunInt() int

func RunRun

func RunRun(args []string) (err error)

func TuiRun added in v0.5.0

func TuiRun(args []string) (err error)

func VetRun added in v0.5.0

func VetRun(args []string) (err error)

func WaitPrintUpdateAvailable added in v0.4.7

func WaitPrintUpdateAvailable()

Types

type ProgramVersion added in v0.4.4

type ProgramVersion struct {
	Version string
	URL     string
}

func CheckUpdate added in v0.4.4

func CheckUpdate(manual bool) (ver ProgramVersion, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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