Documentation
¶
Overview ¶
Package cmdutil provides utility functions specifically for the Guppy CLI.
Index ¶
- func ContentPath(pathStr string) (cid.Cid, string, error)
- func MustGetClient(storePath string, networkCfg config.NetworkConfig, options ...client.Option) *client.Client
- func MustGetClientForNetwork(storePath string, networkCfg config.NetworkConfig, flagName string, ...) *client.Client
- func MustGetIndexClient(networkCfg config.NetworkConfig) (*indexclient.Client, ucan.Principal)
- func MustGetIndexClientForNetwork(networkCfg config.NetworkConfig, flagName string) (*indexclient.Client, ucan.Principal)
- func MustGetNetworkConfig(networkCfg config.NetworkConfig, flagName string) presets.NetworkConfig
- func MustGetProof(path string) delegation.Delegation
- func ParseSize(s string) (uint64, error)
- func ProofResource(proof delegation.Delegation, ability ucan.Ability) (ucan.Resource, bool)
- func ResolveDIDWebAndWrap(ctx context.Context, didWeb did.DID, opts ...principalresolver.Option) (principal.Verifier, error)
- func ResolveSpace(c *client.Client, identifier string) (did.DID, error)
- type HandledCliError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentPath ¶
ContentPath parses a content path string and returns the CID and subpath. A content path can take several forms:
- /ipfs/<cid>[/<subpath>]
- ipfs://<cid>[/<subpath>]
- <cid>[/<subpath>]
The subpath is returned with no leading `/`. If no subpath is specified in the input, an empty string is returned for it.
func MustGetClient ¶
func MustGetClient(storePath string, networkCfg config.NetworkConfig, options ...client.Option) *client.Client
MustGetClient creates a new client suitable for the CLI, using stored data, if any. The storePath should be a directory path where agent data will be stored. The networkCfg contains network settings from the config file.
func MustGetClientForNetwork ¶ added in v0.5.1
func MustGetClientForNetwork(storePath string, networkCfg config.NetworkConfig, flagName string, options ...client.Option) *client.Client
MustGetClientForNetwork is like MustGetClient but allows specifying a network configuration by name (which may be empty). The networkCfg contains network settings from the config file, and flagName is the network name from CLI flag (takes precedence over config).
func MustGetIndexClient ¶
func MustGetIndexClient(networkCfg config.NetworkConfig) (*indexclient.Client, ucan.Principal)
MustGetIndexClient creates a new indexer client using the network configuration.
func MustGetIndexClientForNetwork ¶ added in v0.5.1
func MustGetIndexClientForNetwork(networkCfg config.NetworkConfig, flagName string) (*indexclient.Client, ucan.Principal)
MustGetIndexClientForNetwork creates a new indexer client, allowing a CLI flag to override the network preset name.
func MustGetNetworkConfig ¶ added in v0.5.1
func MustGetNetworkConfig(networkCfg config.NetworkConfig, flagName string) presets.NetworkConfig
MustGetNetworkConfig resolves network configuration from config file and/or CLI flag. The flagName takes precedence over config values when set. Falls back to STORACHA_* env vars if config is empty.
func MustGetProof ¶
func MustGetProof(path string) delegation.Delegation
func ParseSize ¶
ParseSize parses a data size string with optional suffix (B, K, M, G). Accepts formats like: "1024", "512B", "100K", "50M", "2G". Digits with no suffix are interpreted as bytes. Returns the size in bytes.
func ProofResource ¶ added in v0.5.1
func ProofResource(proof delegation.Delegation, ability ucan.Ability) (ucan.Resource, bool)
proofResource finds the resource for a proof, handling the case where the delegated resource is "ucan:*" by recursively checking its proofs to find a delegation for the specific resource.
func ResolveDIDWebAndWrap ¶ added in v0.6.0
func ResolveSpace ¶ added in v0.5.1
ResolveSpace resolves a space identifier, which can be either a DID or a name. If the identifier is a valid DID, it returns that DID directly. Otherwise, it looks up the space by name using the provided client. Returns an error if the name matches no spaces or multiple spaces.
Types ¶
type HandledCliError ¶
type HandledCliError struct {
// contains filtered or unexported fields
}
HandledCliError is an error which has already been presented to the user. If a HandledCliError is returned from a command, the process should exit with a non-zero exit code, but no further error message should be printed.
func NewHandledCliError ¶
func NewHandledCliError(err error) HandledCliError
func (HandledCliError) Unwrap ¶
func (e HandledCliError) Unwrap() error