Documentation
¶
Index ¶
- Constants
- func Describe(err error) *clierr.Error
- func ErrorsAsJSON() bool
- func IsGroup(c *cobra.Command) bool
- func LoginCommand() string
- func LoginHint(err error) string
- func MaybePrintUpdateNudge(out io.Writer)
- func NewRootCmd() *cobra.Command
- func PrintError(w io.Writer, err error, asJSON bool) int
- func StartUpdateCheck(ctx context.Context, subCommand string)
- func WaitForUpdateCheck()
Constants ¶
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
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
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
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 ¶
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 PrintError ¶ added in v0.16.0
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 ¶
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.
Source Files
¶
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 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. |