command

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AclCmd = &cobra.Command{
	Use:     "acl",
	Aliases: []string{"acl"},
	Short:   "Manage data hub client acls from the cli",
	Long: `See available Commands.
Examples:
	mim acl set <clientid> -f acls.json
	mim acl get <clientid>
	mim acl delete <clientid>
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
}
View Source
var ClientCmd = &cobra.Command{
	Use:     "client",
	Aliases: []string{"client"},
	Short:   "Manage data hub clients from the cli",
	Long: `See available Commands.
Examples:
	min client add <clientid> -f key.pub
	mim client delete <clientid>
	mim client list
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
}
View Source
var CompletionCmd = &cobra.Command{
	Use:   "completion [bash|zsh|fish|powershell]",
	Short: "Generate completion script",
	Long: `To load completions:

Bash:

  $ source <(mim completion bash)

  # To load completions for each session, execute once:

  # Linux:
  $ mim completion bash > /etc/bash_completion.d/mim

  # macOS:
  $ mim completion bash > /usr/local/etc/bash_completion.d/mim
  # Mac OS comes with a really old bash version. So in order to
  # get bash completion to work properly, you need to update it:

  $ brew install bash bash-completion
  # Add the new bash shell to the list of available shells:
  $ sudo vim /etc/shells
  # Append /usr/local/bin/bash to the list.
  # Change default shell by running
  $ chsh -s /usr/local/bin/bash
  # If you wish to change default shell for root, run the same
  # command with sudo.

  # Finally to source completions in every session, you need to add
  # this to your ~/.bash_profile
  $ echo "[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion" >> ~/.bash_profile



Zsh:

  # If shell completion is not already enabled in your environment,
  # you will need to enable it.  You can execute the following once:

  $ echo "autoload -U compinit; compinit" >> ~/.zshrc

  # To load completions for each session, execute once:
  $ mim completion zsh > "${fpath[1]}/_mim"

  # You will need to start a new shell for this setup to take effect.

fish:

  $ mim completion fish | source

  # To load completions for each session, execute once:
  $ mim completion fish > ~/.config/fish/completions/mim.fish

PowerShell:

  PS> mim completion powershell | Out-String | Invoke-Expression

  # To load completions for every new session, run:
  PS> mim completion powershell > mim.ps1
  # and source this file from your PowerShell profile.
`,
	DisableFlagsInUseLine: true,
	Hidden:                true,
	ValidArgs:             []string{"bash", "zsh", "fish", "powershell"},
	Args:                  cobra.ExactValidArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		switch args[0] {
		case "bash":
			cmd.Root().GenBashCompletion(os.Stdout)
		case "zsh":
			cmd.Root().GenZshCompletion(os.Stdout)
		case "fish":
			cmd.Root().GenFishCompletion(os.Stdout, true)
		case "powershell":
			cmd.Root().GenPowerShellCompletion(os.Stdout)
		}
	},
}
View Source
var ContentCmd = &cobra.Command{
	Use:     "content",
	Aliases: []string{"contents"},
	Short:   "Manage datahub content from the cli",
	Long: `Manage datahub content from cli such as add, delete, describe and so on. See available Commands.
Examples:
mim content list
mim content add
mim content delete
mim content show
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
	TraverseChildren: true,
}
View Source
var DatasetCmd = &cobra.Command{
	Use:     "dataset",
	Aliases: []string{"datasets"},
	Short:   "Manage datahub datasets from the cli",
	Long: `Manage datahub datasets from cli such as add, delete, describe and so on. See available Commands.
Examples:
mim dataset list
mim dataset create
mim dataset delete
mim dataset entities --name=<dataset>
mim dataset changes --name=<dataset>
mim dataset store --name=<dataset> --filename=<entities file to load>
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
	TraverseChildren: true,
}
View Source
var GatewayCmd = &cobra.Command{
	Use:     "gateway",
	Aliases: []string{"gway"},
	Short:   "Serve a UI gateway",
	Long: `Serves a UI gateway to allow for visual navigation of a connected data hub.
Examples:
mim gateway --login local --port 7042
`,
	Run: func(cmd *cobra.Command, args []string) {
		alias, err := cmd.Flags().GetString("login")
		port, err := cmd.Flags().GetString("port")

		if port == "" {
			port = "7042"
		}
		utils.HandleError(err)

		pterm.Success.Println("Starting gateway on http://localhost:" + port + " with " + alias + " login alias")
		gateway.StartGateway(alias, port)
	},
}
View Source
var JobsCmd = &cobra.Command{
	Use:     "job",
	Aliases: []string{"jobs"},
	Short:   "Manage datahub jobs from the cli",
	Long: `See available Commands.
Examples:
	min job list
	mim job add -f config.json
	mim job delete <jobid>
	mim job get -id <jobid>
	mim job history -id <jobid>
	mim job status -id <jobid>
	mim job operate <jobid> -o start
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
}

jobsCmd represents the jobs command

View Source
var LineageCmd = &cobra.Command{
	Use:   `lineage all|select [<datasetName>]`,
	Short: "retrieve dataset lineage from datahub.",
	Long: `Lineage is a graph of dataset transformation. It shows which datasets go into a dataset and which datasets are produced by a dataset.
Examples:
mim lineage select <datasetName>
mim lineage all
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
}
View Source
var Login2Cmd = &cobra.Command{
	Use:   "login",
	Short: "Log in to the datahub",
	Long: `Log in to the datahub, or add and use login profiles.

Example:
	mim login "<profile>"
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
		out, _ := cmd.Flags().GetBool("out")
		if out {
			pterm.DisableOutput()
		}

		driver := display.ResolveDriver(cmd)
		login.UpdateConfig(args[0])
		pterm.Println("login starting...")
		token, err := login.UseLogin(args[0])
		driver.RenderError(err, true)

		if out {
			fmt.Printf("%s\n", token.AccessToken)
		}

	},
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) != 0 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}
		return login.GetLoginsCompletion(toComplete), cobra.ShellCompDirectiveNoFileComp
	},
}
View Source
var NamespaceCmd = &cobra.Command{
	Use: "namespace",

	Short: "Work with Namespaces from the cli",
	Long: `Examples:
mim namespace ls
mim namespace list
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
	TraverseChildren: true,
}
View Source
var ProviderCmd = &cobra.Command{
	Use:     "provider",
	Aliases: []string{"provider"},
	Short:   "Manage data hub token providers from the cli",
	Long: `See available Commands.
Examples:
	mim provider add -f config.json
	mim provider list
	mim provider delete <providerid>
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
}
View Source
var QueryCmd = &cobra.Command{
	Use:   "query",
	Short: "Query for entities",
	Long: `For example:
mim query --id <entityURI> or
mim query --entity <entityURI> --via <predicateURI> --inverse true | false
`,

	Run: func(cmd *cobra.Command, args []string) {
		format := utils.ResolveFormat(cmd)
		if format == "json" {
			pterm.DisableOutput()
		}

		c := resolveCmds(cmd, args)
		if len(args) == 0 && c.id == "" && len(c.entity) == 0 && c.file == "" {
			_ = cmd.Usage()
			os.Exit(1)
		}

		server, token, err := login.ResolveCredentials()
		utils.HandleError(err)

		sink := outputSink(format)

		if c.file != "" {
			importer := transform.NewImporter(c.file)
			code, err := importer.LoadRaw()
			utils.HandleError(err)

			qb := queries.NewQueryBuilder(server, token)
			result, err := qb.FileQuery(importer.Encode(code), c.timeout)
			utils.HandleError(err)

			output, err := json.Marshal(result)
			if format == "json" {
				fmt.Println(string(output))
			} else {
				f := pretty.Pretty(output)
				out := pretty.Color(f, nil)
				pterm.Printf("%s", string(out))
			}
		} else {
			if c.expanded {
				sink = api.SinkExpander{Sink: sink}
			}
			if c.id != "" {
				out, err := queryScalar(c, server, token)
				utils.HandleError(err)
				err = outputEntities(out, sink)
				utils.HandleError(err)
			} else {
				result, err := queryEntities(c, server, token)
				utils.HandleError(err)

				outputAsEntities, _ := cmd.Flags().GetBool("output-entities")
				if outputAsEntities && format == "json" {
					entities := getEntities(result)
					err = outputEntities(entities, sink)
					utils.HandleError(err)
				} else {
					pr := newPrinter(format, 50)
					if c.expanded {
						pr = &printer.ExpandingPrinter{Printer: pr}
					}
					pr.Header(result[0])
					pr.Print(result[1:])
					pr.Footer()
				}
			}
		}
		pterm.Println()
	},
}

describeCmd represents the describe command

View Source
var StatsCmd = &cobra.Command{
	Use:   "stats",
	Short: "retrieve storage statistics from datahub.",
	Long: `retrieve storage statistics from datahub. statistics are compiled in a long running task in datahub and may not be available before the task is done.
Examples:
mim stats list
mim stats top
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
}
View Source
var TransformCmd = &cobra.Command{
	Use: "transform",

	Short: "Work with Transformations from the cli",
	Long: `Examples:
mim transform import
mim transform test
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
	TraverseChildren: true,
}
View Source
var TxnsCmd = &cobra.Command{
	Use:     "txn",
	Aliases: []string{"transactions"},
	Short:   "Work with transactions from the cli",
	Long: `See available Commands.
Examples:
	mim txn execute -f txn.json
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(0)
		}
	},
}

jobsCmd represents the jobs command

View Source
var VersionCmd = &cobra.Command{
	Use:     "version",
	Aliases: []string{"version"},
	Short:   "See cli version",
	Long:    `See semantic version for this cli release.`,
	Run: func(cmd *cobra.Command, args []string) {
		versionFile, err := versionDir.ReadFile("VERSION")
		var version string
		if err == nil {
			version = string(versionFile)
		} else {
			version = "Only available on released binaries"
		}
		pterm.Println(version)
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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