cmd

package
v0.0.0-...-588d637 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: LGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConfigDir is the directory to store config file
	ConfigDir string
	// DefaultConfigFile is the default config file name
	DefaultConfigFile string
)

Directories

View Source
var (
	// ErrConfigNotMatch indicates error for no config matchs
	ErrConfigNotMatch = "no config matchs"
	// ErrEmptyEndpoint indicates error for empty endpoint
	ErrEmptyEndpoint = "no endpoint has been set"
)

Error strings

View Source
var (

	// RootCmd is single entry point of the CLI
	RootCmd = &cobra.Command{
		Use:          "tronctl",
		Short:        "Tron Blokchain Controller ",
		SilenceUsage: true,
		PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
			if verbose {
				common.EnableAllVerbose()
			}
			switch URLcomponents := strings.Split(node, ":"); len(URLcomponents) {
			case 1:
				node = node + ":50051"
			}
			conn = client.NewGrpcClient(node)

			opts := make([]grpc.DialOption, 0)
			if withTLS {
				opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(nil)))
			} else {
				opts = append(opts, grpc.WithInsecure())
			}

			if trongridKey := os.Getenv("TRONGRID_APIKEY"); len(trongridKey) > 0 {
				apiKey = trongridKey
			}

			conn.SetAPIKey(apiKey)

			if err := conn.Start(opts...); err != nil {
				return err
			}

			if len(signer) > 0 {
				var err error
				if signerAddress, err = findAddress(signer); err != nil {
					return err
				}
			}

			var err error
			passphrase, err = getPassphrase()
			if err != nil {
				return err
			}

			if len(defaultKeystoreDir) > 0 {

				store.SetDefaultLocation(defaultKeystoreDir)
			}

			return nil
		},
		Long: fmt.Sprintf(`
CLI interface to Tron blockchain

%s`, g("type 'tronclt --help' for details")),
		RunE: func(cmd *cobra.Command, args []string) error {
			cmd.Help()
			return nil
		},
	}
)
View Source
var (
	// VersionWrapDump meant to be set from main.go
	VersionWrapDump = ""
)

Functions

func Execute

func Execute()

Execute kicks off the tronctl CLI

func SaveConfig

func SaveConfig(conf *Config) error

SaveConfig to yaml

Types

type Config

type Config struct {
	Node     string `yaml:"node"`
	Ledger   bool   `yaml:"ledger"`
	Verbose  bool   `yaml:"verbose"`
	Timeout  uint32 `yaml:"timeout"`
	NoPretty bool   `yaml:"noPretty"`
	APIKey   string `yaml:"apiKey"`
	WithTLS  bool   `yaml:"withTLS"`
}

Config defines the config schema

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads config file in yaml format

type GitHubRelease

type GitHubRelease struct {
	Prerelease      bool                  `json:"prerelease"`
	TagName         string                `json:"tag_name"`
	TargetCommitish string                `json:"target_commitish"`
	CreatedAt       time.Time             `json:"created_at"`
	Assets          []GitHubReleaseAssets `json:"assets"`
}

GitHubRelease json struct

type GitHubReleaseAssets

type GitHubReleaseAssets struct {
	ID   json.Number `json:"id"`
	Name string      `json:"name"`
	Size json.Number `json:"size"`
	URL  string      `json:"browser_download_url"`
}

GitHubReleaseAssets json struct

type GitHubTag

type GitHubTag struct {
	Ref    string `json:"ref"`
	NodeID string `json:"node_id"`
	URL    string `json:"url"`
	DATA   struct {
		SHA string `json:"sha"`
	} `json:"object"`
}

GitHubTag json struct

Jump to

Keyboard shortcuts

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