pub struct AfdCli { /* private fields */ }Expand description
Agent-First PostgreSQL client.
§Interface Policy
- default mode is canonical agent-first CLI
--mode psqlis argument translation only; runtime output stays JSONL- stdout carries protocol events; stderr is not a protocol channel
§Query Sources and Parameters
- use
--sqlfor inline SQL or--sql-filefor a file - use repeatable
--param N=valuefor positional binds - placeholder count is validated from prepared-statement metadata, not by SQL text scanning
§Connection Sources
--dsn-secretfor a PostgreSQL URI--conninfo-secretfor libpq-style conninfo- or discrete
--host,--port,--user,--dbname,--password-secret - agent-first environment fallbacks:
AFPSQL_* - PostgreSQL environment fallbacks:
PGHOST,PGPORT,PGUSER,PGDATABASE
§Result Shaping
- default mode buffers a bounded inline result
- use
--stream-rowsfor large result sets, with--batch-rowsand--batch-bytesto tune chunk size --output json|yaml|plainchanges rendering only, not the runtime schema
§Examples
afpsql --sql "select now() as now_rfc3339"
afpsql --sql-file ./query.sql
afpsql --sql "select * from users where id = $1" --param 1=123
afpsql --dsn-secret "postgresql://app:secret@127.0.0.1:5432/appdb" --sql "select 1"
afpsql --mode psql -h 127.0.0.1 -p 5432 -U app -d appdb -c "select 1"
afpsql --sql "select * from big_table" --stream-rows --batch-rows 1000
afpsql --mode pipe§Exit Codes
0: query completed successfully1: SQL error or runtime error2: invalid CLI arguments
Trait Implementations§
Source§impl Args for AfdCli
impl Args for AfdCli
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Append to
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§impl CommandFactory for AfdCli
impl CommandFactory for AfdCli
Source§impl FromArgMatches for AfdCli
impl FromArgMatches for AfdCli
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches to self.Source§impl Parser for AfdCli
impl Parser for AfdCli
Source§fn parse_from<I, T>(itr: I) -> Self
fn parse_from<I, T>(itr: I) -> Self
Parse from iterator, exit on error.
Source§fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
Parse from iterator, return Err on error.
Source§fn update_from<I, T>(&mut self, itr: I)
fn update_from<I, T>(&mut self, itr: I)
Auto Trait Implementations§
impl Freeze for AfdCli
impl RefUnwindSafe for AfdCli
impl Send for AfdCli
impl Sync for AfdCli
impl Unpin for AfdCli
impl UnsafeUnpin for AfdCli
impl UnwindSafe for AfdCli
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more