cmd

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

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.GenBashCompletion(os.Stdout)
	},
}
View Source
var BashCompletionLong = `` /* 222-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 CountCmd = &cobra.Command{

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

	Short: "count nodes in file(s)",

	Long: countLong,

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

	},

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

		var globs []string

		if 0 < len(args) {

			globs = args[0:]

		}

		err = CountRun(globs)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var DepthCmd = &cobra.Command{

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

	Short: "calculate the depth of file(s)",

	Long: depthLong,

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

	},

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

		var globs []string

		if 0 < len(args) {

			globs = args[0:]

		}

		err = DepthRun(globs)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var DiffCmd = &cobra.Command{

	Use: "diff <orig> <next>",

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

	Short: "calculate the diff from orig to next file(s)",

	Long: diffLong,

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

	},

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

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

		var orig string

		if 0 < len(args) {

			orig = args[0]

		}

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

		var next string

		if 1 < len(args) {

			next = args[1]

		}

		err = DiffRun(orig, next)
		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...]",

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

	Short: "run file(s) through the hof/flow DAG engine",

	Long: flowLong,

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

	},

	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 InsertCmd = &cobra.Command{

	Use: "insert <code> [files...]",

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

	Short: "insert into file(s) with code (only if not present)",

	Long: insertLong,

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

	},

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

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

		var code string

		if 0 < len(args) {

			code = args[0]

		}

		var globs []string

		if 1 < len(args) {

			globs = args[1:]

		}

		err = InsertRun(code, globs)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var MaskCmd = &cobra.Command{

	Use: "mask <code> [files...]",

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

	Short: "mask from file(s) with code",

	Long: maskLong,

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

	},

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

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

		var code string

		if 0 < len(args) {

			code = args[0]

		}

		var globs []string

		if 1 < len(args) {

			globs = args[1:]

		}

		err = MaskRun(code, globs)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var PatchCmd = &cobra.Command{

	Use: "patch <patch> <orig>",

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

	Short: "apply pacth to orig file(s)",

	Long: patchLong,

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

	},

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

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

		var patch string

		if 0 < len(args) {

			patch = args[0]

		}

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

		var orig string

		if 1 < len(args) {

			orig = args[1]

		}

		err = PatchRun(patch, orig)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var PickCmd = &cobra.Command{

	Use: "pick <code> [files...]",

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

	Short: "pick from file(s) with code",

	Long: pickLong,

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

	},

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

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

		var code string

		if 0 < len(args) {

			code = args[0]

		}

		var globs []string

		if 1 < len(args) {

			globs = args[1:]

		}

		err = PickRun(code, globs)
		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 ReplaceCmd = &cobra.Command{

	Use: "replace <code> [files...]",

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

	Short: "replace in file(s) with code (only if present)",

	Long: replaceLong,

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

	},

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

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

		var code string

		if 0 < len(args) {

			code = args[0]

		}

		var globs []string

		if 1 < len(args) {

			globs = args[1:]

		}

		err = ReplaceRun(code, globs)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var RootCmd = &cobra.Command{

	Use: "cuetils",

	Short: "CUE Utilites for bulk ETL, diff, query, and other operations on data and config",

	Long: cuetilsLong,

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

	},

	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 TransformCmd = &cobra.Command{

	Use: "transform <code> [files...]",

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

	Short: "transform file(s) with code",

	Long: transformLong,

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

	},

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

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

		var code string

		if 0 < len(args) {

			code = args[0]

		}

		var globs []string

		if 1 < len(args) {

			globs = args[1:]

		}

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

	Use: "update",

	Short: "update the cuetils tool",

	Long: UpdateLong,

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

	},

	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 cuetils`
View Source
var UpsertCmd = &cobra.Command{

	Use: "upsert <code> [files...]",

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

	Short: "upsert file(s) with code (extend and replace)",

	Long: upsertLong,

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

	},

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

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

		var code string

		if 0 < len(args) {

			code = args[0]

		}

		var globs []string

		if 1 < len(args) {

			globs = args[1:]

		}

		err = UpsertRun(code, globs)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
View Source
var ValidateCmd = &cobra.Command{

	Use: "validate <schema> [files...]",

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

	Short: "validate file(s) with schema",

	Long: validateLong,

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

	},

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

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

		var schema string

		if 0 < len(args) {

			schema = args[0]

		}

		var globs []string

		if 1 < len(args) {

			globs = args[1:]

		}

		err = ValidateRun(schema, globs)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}
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("cuetils ConfigDir %q %v\n", filepath.Join(s, "cuetils"), 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 cuetils`
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 CallTS

func CallTS(ts *runtime.Script, args []string) error

func CountRun added in v0.1.1

func CountRun(globs []string) (err error)

func DepthRun

func DepthRun(globs []string) (err error)

func DiffRun

func DiffRun(orig string, next string) (err error)

func FlowRun added in v0.4.0

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

func InsertRun added in v0.3.1

func InsertRun(code string, globs []string) (err error)

func InstallUpdate

func InstallUpdate() (err error)

func MaskRun

func MaskRun(code string, globs []string) (err error)

func PatchRun

func PatchRun(patch string, orig string) (err error)

func PickRun

func PickRun(code string, globs []string) (err error)

func PrintUpdateAvailable

func PrintUpdateAvailable()

func ReplaceRun added in v0.1.1

func ReplaceRun(code string, globs []string) (err error)

func RootInit

func RootInit()

func RootPersistentPostRun

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

func RunErr

func RunErr() error

func RunExit

func RunExit()

func RunInt

func RunInt() int

func TransformRun added in v0.1.2

func TransformRun(code string, globs []string) (err error)

func UpsertRun added in v0.1.1

func UpsertRun(code string, globs []string) (err error)

func ValidateRun added in v0.1.2

func ValidateRun(schema string, globs []string) (err error)

func WaitPrintUpdateAvailable

func WaitPrintUpdateAvailable()

Types

type ProgramVersion

type ProgramVersion struct {
	Version string
	URL     string
}

func CheckUpdate

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

Jump to

Keyboard shortcuts

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