bookclerk_plugin_echo_native_rust::cli

Development These docs follow the development version and change with every merge.

Last updated View as Markdown

The cli entrypoint: ping plus the notes commands on the DB binding.

Item Kind Summary
NotesCli struct The cli entrypoint, holding the DB binding the host granted.
cli_schema function CLI schema advertised at PluginCli.describe.
whole_number function Parses a whole-number CLI argument within 1..=maximum.
database_failure function A CLI reply for a failed database call.
MAX_NOTES_PER_ADD constant Largest --count notes-add accepts, so one command stays a modest write.
MAX_NOTES_PER_LIST constant Largest --limit notes-list accepts.

Structs

NotesCli

pub struct NotesCli {
    /* private fields */
}

The cli entrypoint, holding the DB binding the host granted.

NotesCli::new

pub fn new(db: Option<DatabaseBinding>) -> Self

The entrypoint over db.

Implements: PluginCli

Functions

cli_schema

pub fn cli_schema() -> CliSchema

CLI schema advertised at PluginCli.describe.

whole_number

pub fn whole_number(value: &str, maximum: usize) -> Option<usize>

Parses a whole-number CLI argument within 1..=maximum.

Returns

The number, or None when value is not one to six plain decimal digits in range.

database_failure

pub fn database_failure(
    err: PluginError,
    committed: usize,
) -> Result<CliInvokeResult, PluginError>

A CLI reply for a failed database call.

A typed limit names the cap (exit status 1); any other error is passed on so the host reports it, keeping its code.

Arguments

  • err - What the binding returned.
  • committed - Notes already stored by batches that committed before the failure; they stay stored.

Errors

Returns err itself when it is not a limit_exceeded error and nothing was stored; otherwise an error with err's code and details whose message says how many notes were.

Constants

MAX_NOTES_PER_ADD

pub const MAX_NOTES_PER_ADD: usize = 10_000;

Largest --count notes-add accepts, so one command stays a modest write.

MAX_NOTES_PER_LIST

pub const MAX_NOTES_PER_LIST: usize = 1_000;

Largest --limit notes-list accepts.

The listing goes back in one CLI reply, so it is bounded even though NotesReader itself streams.

Generated from examples/plugins-echo-native-rust at main · View as Markdown