cmdutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cmdutil holds the flag helpers that commands share: cursor pagination, partial-update readers, repeatable flags, required flags that can be asked for, idempotency keys, and the content and sender flags of templates and campaigns.

Readers return errors from the errors package, so a bad flag fails as a validation error before the command authenticates.

Index

Constants

View Source
const (
	FromUsage          = "Sender email address"
	ToUsage            = "Recipient email address (can be used multiple times)"
	SubjectUsage       = "Email subject"
	TextUsage          = "Plain text content"
	HTMLUsage          = "HTML content"
	TextFileUsage      = "File with the plain text content"
	HTMLFileUsage      = "File with the HTML content"
	HeaderUsage        = `` /* 128-byte string literal not displayed */
	AttachUsage        = "File to attach"
	SandboxUsage       = "Send in sandbox mode, which delivers nothing"
	SandboxResultUsage = "Sandbox result simulation: %s (needs --sandbox)"
	TagUsage           = "Message tag (can be used multiple times)"
	TrackOpensUsage    = "Track opens (--track-opens=false turns it off); the account's setting applies when omitted"
	TrackClicksUsage   = "Track clicks (--track-clicks=false turns it off); the account's setting applies when omitted"
)

The help of the flags messages send and smtp send share, so each flag reads the same in both. A command adds what applies to it alone, such as when a flag is required.

View Source
const (
	WebhookSends = "each event"
	RouteSends   = "each email"
)

What the URL of a webhook and of a route are sent, in the warning of WarnIfInsecureURL.

View Source
const AttachSizeLimit = "10,485,760 bytes (10 MiB)"

AttachSizeLimit is MaxAttachmentSize in the words of help and errors: in bytes, as the limit of all attachments together is given, and in MiB.

View Source
const MaxAttachmentSize = 10 * 1024 * 1024

MaxAttachmentSize is the largest file --attach accepts, in bytes, which AttachSizeLimit gives as help and errors do.

View Source
const MaxDataFileItems = 1000

MaxDataFileItems is the most items a batch file may hold.

View Source
const MaxNameLength = 255

MaxNameLength is the most characters the API accepts in a name or a label.

Variables

View Source
var (
	// Scopes are the scopes of a webhook or an SMTP credential.
	Scopes = []string{"global", "scoped"}
	// SandboxResults are the results a sandbox send simulates.
	SandboxResults = []string{"deliver", "bounce", "defer", "fail", "suppress"}
	// SubscriptionStatusFilters are the membership statuses a list of
	// memberships can be filtered by.
	SubscriptionStatusFilters = []string{"unconfirmed", "confirmed", "unsubscribed", "complained"}
)

The values of the enum flags that several command groups share, as the API defines them.

Functions

func AddAPIKeyCreateFlags

func AddAPIKeyCreateFlags(cmd *cobra.Command, owner KeyOwner)

AddAPIKeyCreateFlags adds the --label, --scope and --ip-allow-list flags of a command that creates a key of owner. ReadAPIKeyCreate reads them.

func AddAPIKeyUpdateFlags

func AddAPIKeyUpdateFlags(cmd *cobra.Command, owner KeyOwner)

AddAPIKeyUpdateFlags adds the --label, --scope, --ip-allow-list and --clear-ip-allow-list flags of a command that updates a key of owner. ReadAPIKeyUpdate reads them.

func AddCreateContentFlags

func AddCreateContentFlags(cmd *cobra.Command)

AddCreateContentFlags adds the content flags of a create command: --markup-file, --mjml-file, --html-file, --text-file and --editor.

func AddFlagAlias

func AddFlagAlias(cmd *cobra.Command, old, name string)

AddFlagAlias adds old as a hidden, deprecated name of the flag name. Each value given to old is set on name, so the command reads only name. The alias of a bool flag is a switch, as addSwitchAlias describes.

func AddIdempotencyKeyFlag

func AddIdempotencyKeyFlag(cmd *cobra.Command)

AddIdempotencyKeyFlag adds the --idempotency-key flag.

func AddInteractiveAlias

func AddInteractiveAlias(cmd *cobra.Command)

AddInteractiveAlias adds --interactive as a hidden, deprecated switch that sets --non-interactive to false, for a command that had --interactive before --non-interactive replaced it.

func AddLegacyCursorAlias

func AddLegacyCursorAlias(cmd *cobra.Command)

AddLegacyCursorAlias keeps --cursor, the flag older versions paged with, as a hidden, deprecated alias of --after.

func AddMarkupFlag added in v0.4.0

func AddMarkupFlag(cmd *cobra.Command)

AddMarkupFlag adds --markup to the get command of a template, a campaign or a campaign template.

func AddNegatedFlagAlias

func AddNegatedFlagAlias(cmd *cobra.Command, old, name string)

AddNegatedFlagAlias adds old as a hidden, deprecated switch that sets the bool flag name to false: --old is --name=false.

func AddOneOfFlag

func AddOneOfFlag(cmd *cobra.Command, name, value, usage string, values []string)

AddOneOfFlag adds the string flag name, with the default value, whose value is one of values. Its help is usage with the values listed in place of its %s, such as "Sending type: transactional or marketing", and the shell completes the values. MatchOneOf, ReadOneOf and ReadFilterOneOf check a value of it against them.

func AddPaginationFlags

func AddPaginationFlags(cmd *cobra.Command)

AddPaginationFlags adds --limit, --after and --before to a list command whose endpoint pages both ways.

func AddPersistentOneOfFlag

func AddPersistentOneOfFlag(cmd *cobra.Command, name, value, usage string, values []string)

AddPersistentOneOfFlag is AddOneOfFlag for a persistent flag, which the subcommands of cmd take too.

func AddRepeatableFlag

func AddRepeatableFlag(cmd *cobra.Command, name, usage string)

AddRepeatableFlag adds a flag that can be used multiple times. Like every repeatable flag of the CLI, it splits each value on commas, as a CSV line, so --tag a,b is --tag a --tag b. A value that holds a comma must be in double quotes, with any double quote in it doubled: --tag '"news, weekly"'. A value that is not such a CSV line is a validation error.

func AddRepeatableOneOfFlag

func AddRepeatableOneOfFlag(cmd *cobra.Command, name, usage string, values []string)

AddRepeatableOneOfFlag is AddOneOfFlag for a flag that can be given several times, as AddRepeatableFlag adds it; MatchOneOf checks each value.

func AddSenderFlags

func AddSenderFlags(cmd *cobra.Command)

AddSenderFlags adds --from and --from-name.

func AddSenderNameFlag

func AddSenderNameFlag(cmd *cobra.Command)

AddSenderNameFlag adds --from-name, for a command that declares --from itself. ReadSenderName reads it.

func AddUpdateContentFlags

func AddUpdateContentFlags(cmd *cobra.Command)

AddUpdateContentFlags adds the content flags of an update command: --markup-file, --mjml-file, --html-file, --text-file and --regenerate-text.

func AddUpdateSenderFlags

func AddUpdateSenderFlags(cmd *cobra.Command, clearFromUsage string)

AddUpdateSenderFlags adds --from, --from-name and --clear-from, with clearFromUsage as the help of --clear-from.

func AddValueAlias

func AddValueAlias(cmd *cobra.Command, old, name, value string)

AddValueAlias adds old as a hidden, deprecated switch that sets the flag name to value: --old is --name value.

func AskIfEmpty

func AskIfEmpty(cmd *cobra.Command, value, label, missing string) (string, error)

AskIfEmpty returns value, or, when it is empty and prompt.CanPrompt allows it, the answer to a prompt with label. A value that is still empty is the validation error missing.

func ChangedBool

func ChangedBool(cmd *cobra.Command, name string) *bool

ChangedBool returns the value of a bool flag, or nil when the flag was not set on the command line.

func ChangedString

func ChangedString(cmd *cobra.Command, name string) *string

ChangedString returns the value of a string flag, or nil when the flag was not set on the command line. An explicitly empty value is returned as a pointer to "".

func CheckCredentialFlags

func CheckCredentialFlags(cmd *cobra.Command) error

CheckCredentialFlags checks the --api-key and --account-id flags given on the command line: the two go together, the key cannot be empty, and the account ID must be a UUID. It runs before authentication.

func CheckIdempotencyKey

func CheckIdempotencyKey(key string, requests int) error

CheckIdempotencyKey checks --idempotency-key for a command that sends requests requests with the keys of IdempotencyKeyFor: a key with a character that is not printable ASCII, which an HTTP header cannot carry as it is, and a key whose longest form is longer than the API accepts are validation errors.

func CheckMaxCleanedLength

func CheckMaxCleanedLength(name string, value *string, max int, clean func(string) string) error

CheckMaxCleanedLength is CheckMaxLength for a value the API cleans before it counts its characters: it counts value once clean has cleaned it as the API does, such as strings.TrimSpace for a name the API trims, or cleanTemplateText. The value is still sent as given, for the API to clean.

func CheckMaxLength

func CheckMaxLength(name string, value *string, max int) error

CheckMaxLength checks that value, the value of the flag name, has at most max characters, when there is a value.

func CheckReservedHeaders

func CheckReservedHeaders(headers map[string]string, reserved []ReservedHeader) error

CheckReservedHeaders returns a validation error that names the first of reserved that headers holds, in any case, with its hint.

func CheckScopeDomains

func CheckScopeDomains(scope string, domains []string) error

CheckScopeDomains checks the --scope and --domains of a new webhook or SMTP credential: a scoped one needs domains, and a global one takes none, since the API would ignore them and leave it unrestricted.

func CheckSubjectAndPreheader

func CheckSubjectAndPreheader(cmd *cobra.Command) error

CheckSubjectAndPreheader checks that --subject and --preheader, when set, fit maxSubjectLength and maxPreheaderLength, counted as the API counts them, once cleanTemplateText cleaned them.

func CompleteNoFiles

func CompleteNoFiles(cmd *cobra.Command)

CompleteNoFiles makes the shell complete no file name where cmd and its subcommands take none: for every argument without completions of its own, since no command takes a file as an argument, and for every flag that has no completions of its own and is not marked with MarkFileFlag, nor a deprecated name of such a flag. A flag without either would complete file names, Cobra's default.

func CompleteProfileArgument

func CompleteProfileArgument(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

CompleteProfileArgument completes the profile argument of a command that takes one profile name.

func CompleteProfileNames

func CompleteProfileNames(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)

CompleteProfileNames completes the names of the profiles in the configuration file. It reads the file only: it makes no request, and completes nothing, silently, when there is no file.

func CompleteValues

func CompleteValues(cmd *cobra.Command, name string, values []string)

CompleteValues makes the shell complete the flag name of cmd with values, the values the flag's validation accepts.

func DecodeJSON

func DecodeJSON(r io.Reader, target any, subject, kind string) error

DecodeJSON decodes the one JSON value r holds, a value of kind such as "JSON object", into target; every JSON input a user gives is read with it. Numbers are kept as json.Number, so they are sent as written. Input that is empty, is not one value of kind (null included) or does not fit target is a validation error that names the input as subject, such as "--attributes".

func DecodeJSONStrict

func DecodeJSONStrict(r io.Reader, target any, subject, kind string) error

DecodeJSONStrict is DecodeJSON for input whose every key target names, such as a recipients file: a key target lacks, such as a misspelt one, is a validation error that names it.

func ExactArgs

func ExactArgs(n int) cobra.PositionalArgs

ExactArgs accepts exactly n arguments.

func FindHeader

func FindHeader(headers map[string]string, name string) (string, bool)

FindHeader returns the name in headers that is name in any case, and whether there is one.

func IdempotencyKeyFor

func IdempotencyKeyFor(key string, index, requests int) string

IdempotencyKeyFor returns the idempotency key of the request at index, from 0, of a command that sends requests requests: key itself for a single request, otherwise key followed by "-" and index.

func IdempotencyOptions

func IdempotencyOptions(cmd *cobra.Command) ([]api.RequestOption, error)

IdempotencyOptions returns the request option that sends --idempotency-key, or no option when the flag is not given, so the SDK generates the key. A key ReadIdempotencyKey or CheckIdempotencyKey refuses is a validation error; commands call it before authenticating.

func JoinFilter

func JoinFilter(values []string) *string

JoinFilter returns values joined with commas, the form the API takes a filter of several values in, or nil when there are none.

func MarkFileFlag

func MarkFileFlag(cmd *cobra.Command, name string)

MarkFileFlag marks the flag name of cmd as taking a file path, which the shell completes; CompleteNoFiles leaves it so.

func MarkNoEffect

func MarkNoEffect(cmd *cobra.Command, name, hint string)

MarkNoEffect hides the flag name and marks it deprecated, as a flag that is accepted for compatibility and has no effect. hint, when not empty, tells what to use instead.

func MarkupEditor added in v0.4.0

func MarkupEditor(content *requests.TemplateContentInput, editor *string) (*string, error)

MarkupEditor returns the editor a create sends for content, given editor, the value of --editor or nil. Markup is the design of the Simple Editor, so content with markup has the editor simple when --editor is not given, and any other --editor is a validation error. Content without markup keeps editor as it is.

func MatchOneOf

func MatchOneOf(cmd *cobra.Command, name, value string) (string, error)

MatchOneOf returns the value of the flag name, added by AddOneOfFlag, that value matches ignoring case, so the request carries the API's spelling. A value that matches none is a validation error.

func MaximumNArgs

func MaximumNArgs(n int) cobra.PositionalArgs

MaximumNArgs accepts up to n arguments.

func MinimumNArgs

func MinimumNArgs(n int) cobra.PositionalArgs

MinimumNArgs accepts n or more arguments.

func NoArgs

func NoArgs(cmd *cobra.Command, args []string) error

NoArgs accepts no argument.

func NonEmptyString

func NonEmptyString(cmd *cobra.Command, name string) *string

NonEmptyString returns the value of a string flag, or nil when the value is empty or blank, of white space only, so such a filter is left out of the request.

func QuotePath

func QuotePath(path string) string

QuotePath returns path as an argument a user can paste into a command line of the system's shell: on Windows, whose cmd.exe passes single quotes on as part of the argument, path in double quotes when it holds a character other than a letter, a digit or one of windowsPathSafe, such as a space, ', &, ^ or $, and path itself otherwise; elsewhere, path as ShellQuote quotes it.

func ReadAPIKeyCreate

func ReadAPIKeyCreate(cmd *cobra.Command, owner KeyOwner) (requests.CreateAPIKeyRequest, error)

ReadAPIKeyCreate reads the flags AddAPIKeyCreateFlags adds into a create request for a key of owner. A missing label or scope and an invalid scope are validation errors.

func ReadAPIKeyUpdate

func ReadAPIKeyUpdate(cmd *cobra.Command, owner KeyOwner) (requests.UpdateAPIKeyRequest, error)

ReadAPIKeyUpdate reads the flags AddAPIKeyUpdateFlags adds into an update request for a key of owner that holds only the fields given. Giving none of them, an empty value and an invalid scope are validation errors.

func ReadAttachPaths

func ReadAttachPaths(cmd *cobra.Command) ([]string, error)

ReadAttachPaths returns the paths of the repeatable --attach flag, as ReadRepeatable does. A path that does not exist and came from a value the flag split at a comma, as --attach 'inv,2026.txt' splits into inv and 2026.txt, is a validation error that says to quote a file name with a comma.

func ReadClearable

func ReadClearable(cmd *cobra.Command, name, clearFlag string) (*string, bool, error)

ReadClearable returns the value of the string flag name, or nil when it was not set, and whether the bool flag clearFlag, such as --clear-from, was given. A command without clearFlag, such as a create command, has nothing to clear. An empty value is a validation error, which points to clearFlag when the command has it.

func ReadContent

func ReadContent(cmd *cobra.Command) (*requests.TemplateContentInput, error)

ReadContent builds the content from the content flags, or returns nil when none is set. --markup-file goes with neither --mjml-file, as the API refuses MJML beside markup, nor --html-file, which the API ignores beside it.

func ReadDataItems

func ReadDataItems[T any](path, itemsName, itemName string) ([]T, error)

ReadDataItems reads a batch file with readDataFile and decodes each item with decodeDataItem. itemsName names the items and itemName one item in error messages, such as "contacts" and "contact".

func ReadFilterOneOf

func ReadFilterOneOf(cmd *cobra.Command, name string) (*string, error)

ReadFilterOneOf returns the value of the filter flag name, added by AddOneOfFlag, in the spelling of its values, or nil when it is empty, so an empty filter is left out of the request. A value that is not one of its values is a validation error.

func ReadFilterTags

func ReadFilterTags(cmd *cobra.Command) ([]string, error)

ReadFilterTags returns the values of the repeatable flag --tag of a command that filters by tag. The API takes the tags joined with commas and splits them at each comma, so a tag that holds one, given in double quotes, is a validation error: the API would look for its parts instead.

func ReadFlagFile

func ReadFlagFile(flag, path string) (string, error)

ReadFlagFile returns the text of the file at path, which the flag named flag gives, as ReadInputFile reads it.

func ReadHeaders

func ReadHeaders(cmd *cobra.Command, name string) (map[string]string, error)

ReadHeaders returns the custom headers of the repeatable flag name, each given as "Name: value", by header name, or nil when the flag was not set. A value without a colon or a name is a validation error, and so is a name the API refuses: one that holds a space or a character that is not visible ASCII. The name is checked as given, so the part of a header value after an unquoted ", ", which the flag splits off as another header, fails for its leading space; a part after an unquoted "," fails for its missing colon. Both errors say to quote a value with a comma. Header names ignore case, so a name given twice, in any case, is a validation error.

func ReadIdempotencyKey

func ReadIdempotencyKey(cmd *cobra.Command) (string, error)

ReadIdempotencyKey returns --idempotency-key, or "" when it was not given. An empty or blank key, and a key that starts or ends with white space, are validation errors: Go's HTTP client drops the white space around a header value, so the API would get another key than the one given, or none.

func ReadInputFile

func ReadInputFile(flag, path string) ([]byte, error)

ReadInputFile returns the content of the file at path, which the flag named flag gives, without a leading UTF-8 byte order mark; every text or data file a user gives is read with it. A missing or unreadable file, and a file that is not UTF-8 text, are validation errors: the API takes UTF-8, and sending other bytes would replace each character that is not UTF-8.

func ReadListUpdate

func ReadListUpdate(cmd *cobra.Command, name, clearFlag string) (*[]string, error)

ReadListUpdate returns the list an update sends for the repeatable flag name and the bool flag clearFlag: the values, an empty list when clearFlag is set, or nil to keep the list unchanged.

func ReadMarkupFlag added in v0.4.0

func ReadMarkupFlag(cmd *cobra.Command) (bool, error)

ReadMarkupFlag returns whether --markup is set. --markup writes the markup and nothing else, so it cannot be used with --output, even set to false.

func ReadNonEmpty

func ReadNonEmpty(cmd *cobra.Command, name, clearFlag string) (*string, error)

ReadNonEmpty returns the value of a string flag, or nil when the flag was not set. A blank value is a validation error; clearFlag names the flag that clears the field, which the error points to, or is "" when there is none.

func ReadOneOf

func ReadOneOf(cmd *cobra.Command, name string) (*string, error)

ReadOneOf returns the value of the flag name, added by AddOneOfFlag, in the spelling of its values, or nil when the flag was not set. An empty value, or one that is not one of its values, is a validation error.

func ReadOrAsk

func ReadOrAsk(cmd *cobra.Command, name, label string) (string, error)

ReadOrAsk returns the value of the required text flag name. A blank value is the validation error "--name cannot be empty". When the flag is missing and prompt.CanPrompt allows it, it asks for the value with label; a missing value, or a blank answer, is the validation error "--name is required".

func ReadPagination

func ReadPagination(cmd *cobra.Command) (limit *int32, after, before *string, err error)

ReadPagination returns the pagination flags for the command to copy into its SDK params. A zero limit and an empty cursor are returned as nil.

func ReadPaginationParams

func ReadPaginationParams(cmd *cobra.Command) (common.PaginationParams, error)

ReadPaginationParams returns the pagination flags as the SDK's pagination params.

func ReadPastTimeRange

func ReadPastTimeRange(cmd *cobra.Command) (from, to *time.Time, err error)

ReadPastTimeRange returns the times of the --from-time and --to-time flags, each nil when it is empty. A --from-time that is not before --to-time is a validation error.

func ReadRepeatable

func ReadRepeatable(cmd *cobra.Command, name, clearFlag string) ([]string, error)

ReadRepeatable returns the values of a repeatable flag, each without leading and trailing spaces, so --tag "news, weekly" gives news and weekly, or nil when the flag was not set, so the request field it fills stays nil. An empty value, such as the one after a trailing comma, is a validation error; clearFlag names the flag that clears the field, which the error points to, or is "" when there is none.

func ReadRequiredText

func ReadRequiredText(cmd *cobra.Command, name string) (string, error)

ReadRequiredText returns the value of the required text flag name, which it never asks for, unlike ReadOrAsk. A missing flag is the validation error "--name is required", and a blank value is "--name cannot be empty".

func ReadSandboxResult

func ReadSandboxResult(cmd *cobra.Command) (string, error)

ReadSandboxResult returns --sandbox-result in the API's spelling. A value that is not a sandbox result is a validation error, and so is --sandbox-result without --sandbox, which would send real mail.

func ReadSecretOrAsk

func ReadSecretOrAsk(cmd *cobra.Command, name, label string) (string, error)

ReadSecretOrAsk is ReadOrAsk for a secret, such as a password, which is taken as given, so only an empty value fails: it asks with prompt.PromptSecret, so a terminal hides the answer as it is typed.

func ReadSender

func ReadSender(cmd *cobra.Command) (*common.SenderAddress, error)

ReadSender builds the sender from the sender flags, or returns nil when none is set. --clear-from returns an empty address, which the SDK sends as null.

func ReadSenderName

func ReadSenderName(cmd *cobra.Command) (*string, error)

ReadSenderName returns the value of --from-name, or nil when it was not set. --from-name without --from is a validation error.

func ReadTemplateEditor

func ReadTemplateEditor(cmd *cobra.Command, content *requests.TemplateContentInput) (*string, error)

ReadTemplateEditor returns the editor of a template create, as MarkupEditor gives it from --editor, or nil when it is not set. The API needs an editor when the content holds none of markup, MJML and HTML.

func RejectTogether

func RejectTogether(cmd *cobra.Command, first, second string) error

RejectTogether returns a validation error when flags first and second are both set on the command line. The error names each flag as the user gave it, under a deprecated alias when that is the name used, in the order the user gave them.

func ScopesHelp

func ScopesHelp(owner KeyOwner) string

ScopesHelp is the section of the help of a command that takes --scope that lists every scope a key of owner can have, from validation.ScopeGroups.

func ShellQuote

func ShellQuote(value string) string

ShellQuote returns value as a word a user can paste into a command line of a POSIX shell, such as bash or zsh: value itself when it holds only characters no such shell treats specially, otherwise value in single quotes, where each single quote of value ends the quoting, is escaped with a backslash and starts it again. A value that starts with =, which zsh expands to the path of a command, is quoted too.

func TypedName

func TypedName(cmd *cobra.Command, name string) string

TypedName returns the name the user gave the flag name under: a deprecated alias of it, or name itself.

func UsageArguments

func UsageArguments(cmd *cobra.Command) []string

UsageArguments returns the names of the arguments the usage line of cmd names, such as sub-account-id and key-id for "get <sub-account-id> <key-id>", and domain for "create [domain]". Flag values, such as <label> in "--label <label>", are not arguments.

func ValidateWebhookURL

func ValidateWebhookURL(name, rawURL string) error

ValidateWebhookURL checks that rawURL, the value of the flag name, is an absolute HTTP or HTTPS URL. Commands that accept it call WarnIfInsecureURL once every other input is valid.

func WarnIfInsecureURL

func WarnIfInsecureURL(cmd *cobra.Command, name, rawURL, sent string)

WarnIfInsecureURL writes validation.PlainHTTPWarning to stderr when rawURL, the value of the flag name, sends what it is sent over plain HTTP to a host that is not a loopback host; sent names that, such as "each event" for a webhook or "each email" for a route. Warnings never reach stdout, so JSON output stays the API response alone.

func WriteMarkup added in v0.4.0

func WriteMarkup(cmd *cobra.Command, what, id string, content *responses.TemplateContent) error

WriteMarkup writes the AhaML of content, the design of what ("template", "campaign" or "campaign template") id, to stdout and nothing else: to a file or a pipe exactly as the API returned it, and to a terminal escaped as table and plain output escape their text. Content with no AhaML is an error that says why.

Types

type Attachment

type Attachment struct {
	// Path is the path given to --attach.
	Path string
	Data []byte
}

Attachment is a file read for --attach.

func ReadAttachments

func ReadAttachments(paths []string) ([]Attachment, error)

ReadAttachments reads every --attach file, so a send fails before it connects when one cannot be attached. A missing or unreadable file, a directory or other file that is not a regular one, such as a device or a named pipe, and a file over MaxAttachmentSize are validation errors.

type KeyOwner

type KeyOwner int

KeyOwner is whose API key a command creates or updates, which decides the scopes the key can have.

const (
	// AccountKey is a key of the account the CLI authenticates as.
	AccountKey KeyOwner = iota
	// SubAccountKey is a key of one of its sub-accounts, which cannot have
	// the scopes that manage sub-accounts.
	SubAccountKey
)

type ReservedHeader

type ReservedHeader struct {
	Name string
	Hint string
}

ReservedHeader is a header name that --header refuses, in any case, with the hint that says how to set it instead.

Jump to

Keyboard shortcuts

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