cmd

package
v1.73.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: Apache-2.0 Imports: 31 Imported by: 1

Documentation

Overview

DBDeployer - The MySQL Sandbox Copyright © 2006-2022 Giuseppe Maxia

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var DoubleStringExport = ExportAnnotation{
	Arguments: []RequiredInfo{
		{HowMany: 2, Name: globals.ExportString},
	},
}

An annotation defining two generic string arguments

View Source
var ReplicationExport = ExportAnnotation{
	Arguments: []RequiredInfo{
		{HowMany: 1, Name: globals.ExportVersionDir},
	},
	Options: []RequiredInfo{
		{HowMany: 1, Name: globals.ExportTopology, ReferenceData: globals.ExportAllowedTopologies},
	},
}

An annotation defining what are the minimum required arguments for replication

View Source
var StringExport = ExportAnnotation{
	Arguments: []RequiredInfo{
		{HowMany: 1, Name: globals.ExportString},
	},
}

An annotation defining an argument as a generic string

View Source
var TemplateGroupExport = ExportAnnotation{
	Arguments: []RequiredInfo{
		{HowMany: 1, Name: globals.ExportTemplateGroup},
		{HowMany: 1, Name: globals.ExportTemplateName},
	},
}

An annotation defining a string parameter of type sandbox template-group

View Source
var TemplateNameExport = ExportAnnotation{
	Arguments: []RequiredInfo{
		{HowMany: 1, Name: globals.ExportTemplateName},
	},
}

An annotation defining a string parameter of type sandbox template-name

Functions

func CommandToJson added in v1.28.0

func CommandToJson(c Command) string

Converts a Command structure to JSON

func DryRunCmd added in v1.29.0

func DryRunCmd(cmd string, dryRun bool) (string, error)

func DryRunCmdWithArgs added in v1.29.0

func DryRunCmdWithArgs(cmd string, args []string, dryRun bool) (string, error)

func Execute

func Execute() int

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func ExportAnnotationToJson added in v1.28.0

func ExportAnnotationToJson(ea ExportAnnotation) string

Converts an annotation structure to a JSON string

func ExportJson added in v1.28.0

func ExportJson() string

Exports the whole dbdeployer structure to JSON

func ExportJsonNamed added in v1.28.0

func ExportJsonNamed(name string, subCommand string) string

Export a given sub-command as JSON

func SandboxNames added in v1.28.0

func SandboxNames(n int) cobra.PositionalArgs

Types

type Command added in v1.28.0

type Command struct {
	Version         string           `json:"version,omitempty"`     // dbdeployer version
	Name            string           `json:"name"`                  // Name of the command itself
	Use             string           `json:"use"`                   // How to use it
	Aliases         []string         `json:"aliases,omitempty"`     // Alternative names for this command
	Short           string           `json:"short,omitempty"`       // Short usage description
	Long            string           `json:"long,omitempty"`        // Long usage description
	Example         string           `json:"example,omitempty"`     // Usage examples, if any
	Breadcrumbs     []string         `json:"ancestors"`             // sequence of commands up to this (sub)command
	SubCommands     []Command        `json:"commands,omitempty"`    // Children of this (sub)command
	Options         []Option         `json:"flags,omitempty"`       // List of flags valid for this command
	NeedSubCommands bool             `json:"needs_sub_commands"`    // When the command alone cannot execute
	Annotations     ExportAnnotation `json:"annotations,omitempty"` // Arguments and constraints for this command
}

Describes a command (or sub-command)

func Export added in v1.28.0

func Export() Command

Returns the dbdeployer structure as a Command type This is used to create Go applications with a different user interface

type ExportAnnotation added in v1.28.0

type ExportAnnotation struct {
	Arguments []RequiredInfo `json:"arguments,omitempty"` // Required or recommended arguments
	Options   []RequiredInfo `json:"options,omitempty"`   // Options needed for this command
}

Defines what is needed for a command at the end of the known keywords

type Option added in v1.28.0

type Option struct {
	Name     string `json:"name"`     // Name of the option
	Type     string `json:"type"`     // Type
	Usage    string `json:"usage"`    // Brief help on how to use this option
	Shortcut string `json:"shortcut"` // Option abbreviation
	Default  string `json:"default"`  // Default value
}

Describes a command option

type RequiredInfo added in v1.28.0

type RequiredInfo struct {
	HowMany       int    `json:"n"`                  // How many times this item should be used
	Name          string `json:"name"`               // Name of the item
	ReferenceData string `json:"ref_data,omitempty"` // Data used for multiple choice (if available)
}

Describes the parameters needed after a known parameter such as a command keyword or an option

type TemplateInfo

type TemplateInfo struct {
	TemplateInFile bool
	Group          string
	Name           string
	Description    string
}

Jump to

Keyboard shortcuts

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