cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 35 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 cli implements the nota command line. Every command works on one vault (found by vault.Discover), keeps the index up to date before it reads from it, and prints JSON instead of text with --json.

Index

Constants

View Source
const (
	ExitOK        = 0
	ExitError     = 1 // anything else: IO, broken index, editor failed
	ExitUsage     = 2 // bad flags or arguments
	ExitNotFound  = 3 // no such note, view or vault
	ExitAmbiguous = 4 // a note reference matched several notes
	ExitConflict  = 5 // the target exists or differs only in case
)

Exit codes. Scripts can rely on them.

View Source
const (
	EnvServerAddr        = "NOTA_SERVER_ADDR"
	EnvServerData        = "NOTA_SERVER_DATA"
	EnvServerMaxFileSize = "NOTA_SERVER_MAX_FILE_SIZE"
	EnvServerLogFormat   = "NOTA_SERVER_LOG_FORMAT"
	// EnvServerPublicURL is the API's own public URL.
	EnvServerPublicURL = "NOTA_SERVER_PUBLIC_URL"
	// EnvServerWebOrigin lists the web app's origins, comma-separated;
	// the first is where sign-in links point.
	EnvServerWebOrigin = "NOTA_SERVER_WEB_ORIGIN"
	// EnvServerRPID is the WebAuthn relying party id (passkeys are off
	// without it).
	EnvServerRPID = "NOTA_SERVER_RP_ID"
	// EnvServerCookieDomain is the session cookie's Domain.
	EnvServerCookieDomain = "NOTA_SERVER_COOKIE_DOMAIN"
	// EnvServerCookieInsecure=1 drops the cookie's Secure flag (local http only).
	EnvServerCookieInsecure = "NOTA_SERVER_COOKIE_INSECURE"
	// EnvServerSignup is invite (default), open or closed.
	EnvServerSignup = "NOTA_SERVER_SIGNUP"
	// EnvServerTrustedProxies lists proxies (IPs, CIDRs or "private")
	// whose X-Forwarded-For is believed.
	EnvServerTrustedProxies = "NOTA_SERVER_TRUSTED_PROXIES"
	// EnvServerPollInterval is the device-code poll interval (default 5s).
	EnvServerPollInterval = "NOTA_SERVER_POLL_INTERVAL"
	// EnvServerHooks=on runs each vault's .nota/hooks.toml on the server
	// (default off).
	EnvServerHooks = "NOTA_SERVER_HOOKS"
)

Server environment variables. Flags win over them.

View Source
const DefaultServer = "https://nota.app.banjoanton.com"

DefaultServer is the Nota server `nota login` uses when no URL is given and the vault has no remote.

View Source
const EnvNow = "NOTA_NOW"

EnvNow fixes the clock for timestamps written into notes (RFC 3339). It exists for tests and reproducible scripts.

View Source
const EnvServerURL = "NOTA_SERVER_URL"

EnvServerURL overrides DefaultServer.

Variables

View Source
var Version = "dev"

Version is set at build time with -ldflags "-X github.com/banjo/nota/internal/cli.Version=…".

Functions

func Main

func Main(args []string, stdin io.Reader, stdout, stderr io.Writer) int

Main runs the CLI with args (without the program name) and returns the process exit code.

Types

type Error

type Error struct {
	Code    int      `json:"-"`
	Kind    string   `json:"code"`
	Message string   `json:"message"`
	Matches []string `json:"matches,omitempty"`
}

Error is an error with an exit code and a stable machine-readable kind.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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