Cohesive Systems logoCOHESIVE SYSTEMS

Search Cohesive Systems

Ready

Search Cohesive Systems

Find product pages, building blocks, technical articles, and graph definitions.

Building Blocks

Cohesive.Cli

Cohesive.Cli provides reusable typed command composition, configuration binding, validation, standard-stream routing, cancellation, and testable invocation without requiring the broader application host.

Core Idea

A command tree owns typed configuration, generated help, validation, middleware, input and output routing, cancellation, and invocation diagnostics. Host lifecycle and dependency-injection integration remain optional in Cohesive.Host.

Why It Exists

Products often need APIs, workers, local developer tools, migration commands, admin commands, test harnesses, and training job runners. Those surfaces drift when CLI parsing, appsettings, environment variables, profiles, and service activation are implemented separately.

Cohesive.Cli treats command-line values as one input to the same typed configuration pipeline as the rest of the app, while staying independent of storage, transitions, processes, relations, and the generic host.

Command Declaration

A CLI application is declared as a command tree. Commands bind typed configuration, declare options and arguments, attach validators, add middleware, and register handlers.

The shape is intentionally close to Minimal APIs: declare the app, map commands, bind typed input, compose middleware, and run.

Parameter Binding

Parameters come from Cohesive.Configuration metadata. The same parameter definition can drive command-line options, positional arguments, environment-variable binding, appsettings binding, required-value checks, allowed values, time unit conversion, and collection parsing.

Runtime Boundary

The core package is provider-neutral. Handlers receive typed configuration, command context, cancellation, and invocation-scoped I/O without acquiring an application-host dependency.

Commands that need generic-host lifecycle or dependency-injection scopes add the separate Cohesive.Host package. This keeps small tools and embedded command trees lightweight while allowing hosted applications to attach their service provider through a deliberate integration boundary.

Testing and Output

CommandIo owns standard input, output, error, UTF-8 text, JSON serialization, and file routing. File output is replaced atomically after a successful write; standard output streams directly. The test harness can invoke commands with captured channels and exit codes without shelling out to another process.