CliContext class

Where the CLI's global options come from, and how they resolve to a store.

The CLI works two ways and the same commands drive both:

  • Remote (--server https://store.example.com) — an OmnyStoreClient. What CI and operators use.
  • Local (--data /var/lib/omnystore) — an embedded OmnyStore over a directory. What a single-machine registry uses, and what omnystore server serves.

Options fall back to environment variables (OMNYSTORE_URL, OMNYSTORE_TOKEN, OMNYSTORE_DATA), because a CI job should set a secret once rather than repeat --token on every command — and because a token on a command line is visible in the process table to every user on the machine.

Constructors

CliContext({required OmnyStoreApi store, bool jsonOutput = false, bool quiet = false, StringSink? out, StringSink? err, Future<void> onClose()?})
Creates a context.

Properties

err StringSink
Where errors and progress go.
final
hashCode int
The hash code for this object.
no setterinherited
jsonOutput bool
Whether output should be JSON rather than human-readable text.
final
out StringSink
Where normal output goes.
final
quiet bool
Whether to suppress progress and informational output.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
store OmnyStoreApi
The resolved store: a client or an embedded store.
final

Methods

close() Future<void>
Releases the store's resources.
info(String message) → void
Writes message followed by a newline, unless quiet.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
progress(String message) → void
Writes message to stderr as progress, unless quiet.
toString() String
A string representation of this object.
inherited
writeJson(Object? data) → void
Emits data as pretty-printed JSON.
writeOne(dynamic model, String text) → void
Emits a single model as JSON, or text when not in JSON mode.
writeTable(List models, {required List<String> headers, required List<List<String>> rows, String emptyMessage = 'Nothing to show.'}) → void
Emits models as JSON when --json is set, otherwise renders rows as an aligned table.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

addGlobalOptions(ArgParser parser) → void
Adds the global options every command shares to parser.
loggerFor({required bool verbose, StringSink? sink}) Logger
A logger writing structured lines to stderr, or a no-op when not verbose.
openLocalStore(String path, {Logger logger = const NoopLogger(), String providerId = 'local'}) Future<OmnyStore>
Opens an embedded store rooted at path.
resolve(ArgResults options, Map<String, String> environment, {StringSink? out, StringSink? err}) Future<CliContext>
Builds a context from parsed global options and the environment.