options

package
v0.0.0-...-f94ef0f Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package options contains a set of common CLI options and helper functions to use them.

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout is the default timeout used for RPC requests.

View Source
const RPCEndpointFlag = "rpc-endpoint"

RPCEndpointFlag is a long flag name for RPC endpoint. It can be used to check for flag presence in the context.

Variables

View Source
var Network = []cli.Flag{
	cli.BoolFlag{Name: "privnet, p"},
	cli.BoolFlag{Name: "mainnet, m"},
	cli.BoolFlag{Name: "testnet, t"},
	cli.BoolFlag{Name: "unittest", Hidden: true},
}

Network is a set of flags for choosing the network to operate on (privnet/mainnet/testnet).

View Source
var RPC = []cli.Flag{
	cli.StringFlag{
		Name:  RPCEndpointFlag + ", r",
		Usage: "RPC node address",
	},
	cli.DurationFlag{
		Name:  "timeout, s",
		Usage: "Timeout for the operation",
		Value: 10 * time.Second,
	},
}

RPC is a set of flags used for RPC connections (endpoint and timeout).

Functions

func GetNetwork

func GetNetwork(ctx *cli.Context) uint64

GetNetwork examines Context's flags and returns the appropriate network. It defaults to PrivNet if no flags are given.

func GetRPCClient

func GetRPCClient(gctx context.Context, ctx *cli.Context) (*client.Client, cli.ExitCoder)

GetRPCClient returns an RPC client instance for the given Context.

func GetTimeoutContext

func GetTimeoutContext(ctx *cli.Context) (context.Context, func())

GetTimeoutContext returns a context.Context with default of user-set timeout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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