cmd

package
v0.6.7-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: BSD-3-Clause Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const RootCustomHelp = `` /* 999-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 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 location>",

	Short: "easily bootstrap full project, components, and more",

	Long: createLong,

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

		ga.SendCommandPath(cmd.CommandPath())

	},

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

		var module string

		if 0 < len(args) {

			module = args[0]

		}

		err = CreateRun(module)
		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,

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

		ga.SendCommandPath(cmd.CommandPath())

	},
}
View Source
var FeedbackCmd = &cobra.Command{

	Use: "feedback [email] <message>",

	Aliases: []string{
		"hi",
		"say",
		"from",
		"bug",
		"yo",
		"hello",
		"greetings",
		"support",
	},

	Short: "send feedback, bug reports, or any message",

	Long: feedbackLong,

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

		ga.SendCommandPath(cmd.CommandPath())

	},

	Run: func(cmd *cobra.Command, args []string) {
		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 CUE pipelines with the hof/flow DAG engine",

	Long: flowLong,

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

		ga.SendCommandPath(cmd.CommandPath())

	},

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

		var globs []string

		if 0 < len(args) {

			globs = args[0:]

		}

		err = FlowRun(globs)
		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
	},

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

		ga.SendCommandPath(cmd.CommandPath())

	},

	Run: func(cmd *cobra.Command, args []string) {
		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: "modular and composable code gen: CUE & data + templates = _",

	Long: genLong,

	PreRun: 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)

	},

	Run: func(cmd *cobra.Command, args []string) {
		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: "polyglot dependency management based on go mods and MVS",

	Long: modLong,

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

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

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

		ga.SendCommandPath(cmd.CommandPath())

	},
}
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 High Code 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,

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

		ga.SendCommandPath(cmd.CommandPath())

	},

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

		err = RunRun(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: "v" + 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) {

		s, e := os.UserConfigDir()
		fmt.Printf("hof ConfigDir %q %v\n", filepath.Join(s, "hof"), e)

		fmt.Printf(
			versionMessage,
			verinfo.Version,
			verinfo.Commit,
			verinfo.BuildDate,
			verinfo.GoVersion,
			verinfo.BuildOS,
			verinfo.BuildArch,
		)
	},
}
View Source
var VersionLong = `Print the build version for hof`
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 CreateRun added in v0.5.0

func CreateRun(module 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(entrypoints []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 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