Livt packages
Eccelerators.Cli
Version 1.4.1
Transport-independent, bounded command-line input, parsing, editing, and output for Livt FPGA applications.
Published files (23)
src/CommandDispatcher.lvt
namespace Eccelerators.Cli
using Livt.IO
/**
* Executes a registry wired before processing begins. One caller serializes
* Dispatch with CLI input and output; only this component completes commands.
*/
component CommandDispatcher<LINE_STORAGE: IRam<byte> & new() = Ram<byte, 64, MemoryStyle.Block>,
OUTPUT_STORAGE: IRam<byte> & new() = Ram<byte, 64, MemoryStyle.Block>>
{
// Borrowed terminal and immutable registry topology; no command names here.
cli: Cli<LINE_STORAGE, OUTPUT_STORAGE>
registry: ICommandRegistry
/**
* Borrows a CLI with matching storage types and an immutable command registry.
* The owner serializes dispatch with input/output and keeps both dependencies alive.
*/
new(cli: Cli<LINE_STORAGE, OUTPUT_STORAGE>, registry: ICommandRegistry)
{
this.cli = cli
this.registry = registry
}
/**
* Completes input only after its entire response is accepted. A blocked
* response leaves input pending for retry through the same registered chain.
*/
public fn Dispatch()
{
if (!this.cli.HasCommand()) {
return
}
if (this.registry.TryRespond()) {
this.cli.CompleteCommand()
}
}
}