cli

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const EnvErrorFormat = "NORCUBE_ERROR_FORMAT"

EnvErrorFormat set to "json" makes every error a JSON object on stderr, whatever the output format.

Variables

This section is empty.

Functions

func Describe added in v0.16.0

func Describe(err error) *clierr.Error

Describe turns any error the CLI returns into a *clierr.Error with a code, message and hint. API errors already are one; the rest are classified here.

func ErrorsAsJSON added in v0.16.0

func ErrorsAsJSON() bool

ErrorsAsJSON reports whether errors are written as JSON: with NORCUBE_ERROR_FORMAT=json, or when the command's output is json or yaml.

func IsGroup added in v0.17.0

func IsGroup(c *cobra.Command) bool

IsGroup reports whether c only groups subcommands: running it alone shows help. Documentation generators use it to skip a usage line.

func LoginCommand added in v0.16.0

func LoginCommand() string

LoginCommand is the command that signs the running command's profile in, for error hints. It names the profile unless the profile is the one a plain `norcube login` signs in anyway.

func LoginHint added in v0.16.0

func LoginHint(err error) string

LoginHint is the message for an error that a login fixes: one line when the profile has no session, the server's reason plus the fix when the session was refused.

func MaybePrintUpdateNudge

func MaybePrintUpdateNudge(out io.Writer)

MaybePrintUpdateNudge writes a one-line "new release available" footer to `out` when the cache says a newer version exists. Safe no-op when the cache is empty or the running binary is already current.

func NewRootCmd

func NewRootCmd() *cobra.Command

func PrintError added in v0.16.0

func PrintError(w io.Writer, err error, asJSON bool) int

PrintError writes err to w, as {"error": {...}} when asJSON, otherwise as the message and, on its own line, the hint. It returns the exit code.

func StartUpdateCheck

func StartUpdateCheck(ctx context.Context, subCommand string)

StartUpdateCheck primes the in-process cache from disk and, if the cached answer is stale (or absent), spawns a background goroutine that hits the GitHub Releases API. The goroutine writes to the cache file so a slow first run still benefits a fast second run. Call WaitForUpdateCheck before MaybePrintUpdateNudge in main, so a freshly fetched result has a chance to land before we decide whether to nudge.

Skips entirely when:

  • the running subcommand is `upgrade` (does its own check),
  • stderr isn't a TTY (piped output, CI),
  • NORCUBE_NO_UPDATE_CHECK is set,
  • the binary was built without -ldflags (Version == "dev").

func WaitForUpdateCheck

func WaitForUpdateCheck()

WaitForUpdateCheck blocks for up to updateCheckWaitBudget if a background check is in flight. No-op when StartUpdateCheck didn't launch one (cache was fresh, or the check was skipped).

Types

This section is empty.

Directories

Path Synopsis
Package backup implements the `norcube backup ...` command tree (snapdb is the backend service behind the Norcube Backup product).
Package backup implements the `norcube backup ...` command tree (snapdb is the backend service behind the Norcube Backup product).
Package billing implements the `norcube billing ...` command tree: the organization's account status, subscriptions, usage estimate, invoices and spending caps.
Package billing implements the `norcube billing ...` command tree: the organization's account status, subscriptions, usage estimate, invoices and spending caps.
Package domainradar implements the `norcube domainradar ...` command tree: domain checks, bulk checks, saved domains, brand monitoring and the name generator.
Package domainradar implements the `norcube domainradar ...` command tree: domain checks, bulk checks, saved domains, brand monitoring and the name generator.
Package langsync implements the `norcube langsync ...` command tree.
Package langsync implements the `norcube langsync ...` command tree.
projectcfg
Package projectcfg loads and writes the per-project Langsync config (`.langsync.json`).
Package projectcfg loads and writes the per-project Langsync config (`.langsync.json`).
projectcfg/translations
Package translations reads and writes language files for the sync command.
Package translations reads and writes language files for the sync command.
Package monitor implements the `norcube monitor ...` command tree: uptime, SSL certificate and domain expiry monitors, their check history, incidents and alert channels, public status pages, and an organization-wide status for scripts and CI.
Package monitor implements the `norcube monitor ...` command tree: uptime, SSL certificate and domain expiry monitors, their check history, incidents and alert channels, public status pages, and an organization-wide status for scripts and CI.

Jump to

Keyboard shortcuts

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