cmd

package
v2.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "glc",
	Short: "gitlab cli",
	Long:  "gitlab Command Line Application",
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		config = loadConfig(configFile, cmdRequireClient(cmd.Use))

		if cmdRequireClient(cmd.Use) {
			client = gitlab.NewGitlab(config.Host, config.ApiPath, config.Token)
		}

		if noColor {
			color.NoColor = true
		}

		if isInteractive {
			loader = spinner.New(spinner.CharSets[14], 60*time.Millisecond)
		} else {
			loader = new(FakeLoader)
		}

		if outputFormat == "" {
			if config != nil && config.OutputFormat != "" {
				outputFormat = config.OutputFormat
			} else {
				outputFormat = "text"
			}
		}

		if !silent {
			writers = append(writers, os.Stdout)
		}
		if outputDestination != "" {
			fileWriter, err := os.Create(outputDestination)
			if err != nil {
				fmt.Println(err)
				return
			}

			writers = append(writers, fileWriter)
		}
		output = io.MultiWriter(writers...)
	},
}

Functions

func Execute

func Execute()

Types

type Alias

type Alias struct {
	Alias        string            `yaml:"alias"`
	ResourceType string            `yaml:"resource_type"`
	ResourceIds  map[string]string `yaml:"resource_ids"`
}

func (*Alias) IdValues

func (a *Alias) IdValues() []string

func (*Alias) IdsString

func (a *Alias) IdsString() string

type Config

type Config struct {
	Host         string   `yaml:"host"`
	ApiPath      string   `yaml:"api_path"`
	Token        string   `yaml:"token"`
	OutputFormat string   `yaml:"output_format,omitempty"`
	Aliases      []*Alias `yaml:"aliases"`
}

func (*Config) Write

func (c *Config) Write(path string)

type FakeLoader

type FakeLoader struct{}

func (*FakeLoader) Start

func (fl *FakeLoader) Start()

func (*FakeLoader) Stop

func (fl *FakeLoader) Stop()

type Loader

type Loader interface {
	Start()
	Stop()
}

Jump to

Keyboard shortcuts

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