cmd

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2018 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CompletionCmd = &cobra.Command{
	Use:   "completion",
	Short: TRCLI("cli.completion.summary"),
	Long:  TRCLI("cli.completion.description"),
	RunE: func(cmd *cobra.Command, args []string) error {
		err := RootCmd.GenBashCompletion(os.Stdout)
		if err != nil {
			return err
		}
		return nil
	},
}

CompletionCmd defines 'completion' subcommand

View Source
var ConfigureCmd = &cobra.Command{
	Use:   "configure",
	Short: TRCLI("cli.configure.summary"),
	Long:  TRCLI("cli.configure.description"),
	RunE: func(cmd *cobra.Command, args []string) error {
		pn := getSpecifiedProfileName()
		if pn == "" {
			pn = "default"
		}

		profile, err := collectProfileInfo(pn)
		if err != nil {
			cmd.SilenceUsage = true
			return err
		}

		err = saveProfile(pn, profile)
		if err != nil {
			cmd.SilenceUsage = true
			return err
		}

		return nil
	},
}

ConfigureCmd defines 'configure' subcommand

View Source
var ConfigureGetCmd = &cobra.Command{
	Use:   "get",
	Short: TRCLI("cli.configure.get.summary"),
	Long:  TRCLI("cli.configure.get.description"),
	RunE: func(cmd *cobra.Command, args []string) error {
		pn := getSpecifiedProfileName()
		if pn == "" {
			pn = "default"
		}

		p, err := loadProfile(pn)
		if err != nil {
			return err
		}

		return prettyPrintObjectAsJSON(p)
	},
}

ConfigureGetCmd defineds 'get' subcommand

View Source
var ConfigureSandboxAuthKey string
View Source
var ConfigureSandboxAuthKeyID string
View Source
var ConfigureSandboxCmd = &cobra.Command{
	Use:   "configure-sandbox",
	Short: TRCLI("cli.configure_sandbox.summary"),
	Long:  TRCLI("cli.configure_sandbox.description"),
	RunE: func(cmd *cobra.Command, args []string) error {
		pn := getSpecifiedSandboxProfileName()

		var p *profile
		var err error
		if ConfigureSandboxAuthKeyID == "" || ConfigureSandboxAuthKey == "" || ConfigureSandboxEmail == "" || ConfigureSandboxPassword == "" {
			p, err = collectSandboxProfileInfo(pn)
			if err != nil {
				cmd.SilenceUsage = true
				return err
			}
			ep := getSpecifiedSandboxEndpoint(p.CoverageType)
			p.Endpoint = &ep
		} else {
			ct := getSpecifiedCoverageType()
			ep := getSpecifiedSandboxEndpoint(ct)
			p = &profile{
				Sandbox:      true,
				CoverageType: ct,
				Endpoint:     &ep,
				AuthKeyID:    &ConfigureSandboxAuthKeyID,
				AuthKey:      &ConfigureSandboxAuthKey,
				Email:        &ConfigureSandboxEmail,
				Password:     &ConfigureSandboxPassword,
			}
		}

		_, err = sandboxInit(p)
		if err != nil {
			cmd.SilenceUsage = true
			return err
		}

		p.AuthKeyID = nil
		p.AuthKey = nil

		err = saveProfile(pn, p)
		if err != nil {
			cmd.SilenceUsage = true
			return err
		}

		return nil
	},
}

ConfigureSandboxCmd defines 'configure-sandbox' subcommand

View Source
var ConfigureSandboxEmail string
View Source
var ConfigureSandboxPassword string
View Source
var UnconfigureCmd = &cobra.Command{
	Use:   "unconfigure",
	Short: TRCLI("cli.unconfigure.summary"),
	Long:  TRCLI("cli.unconfigure.description"),
	RunE: func(cmd *cobra.Command, args []string) error {
		pn := getSpecifiedProfileName()
		if pn == "" {
			pn = "default"
		}

		if confirmDeleteProfile(pn) {
			err := deleteProfile(pn)
			if err != nil {
				cmd.SilenceUsage = true
				return err
			}
		}

		return nil
	},
}

UnconfigureCmd defines 'unconfigure' subcommand

View Source
var VersionCmd = &cobra.Command{
	Use:   "version",
	Short: TRCLI("cli.version.summary"),
	Long:  TRCLI("cli.version.description"),
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Printf("SORACOM API client v%s\n", version)
	},
}

VersionCmd defines 'version' subcommand

Functions

func TRAPI added in v0.2.4

func TRAPI(pathAndMethodAndField string) string

func TRCLI added in v0.2.4

func TRCLI(resourceID string) string

Types

This section is empty.

Source Files

  • apiclient.go
  • auth_helper.go
  • completion.go
  • configure.go
  • configure_get.go
  • configure_sandbox.go
  • endpoint.go
  • lang_utils.go
  • pretty_print_json.go
  • profiles.go
  • sprintf.go
  • version.go

Jump to

Keyboard shortcuts

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