pub struct Ctx {
pub api_key: Option<String>,
pub environment: Environment,
pub api_base: Option<String>,
pub config_path: PathBuf,
pub wallet_address: Option<String>,
pub keystore_path: Option<PathBuf>,
pub confirm_above_budget: Option<String>,
pub log_format: Option<String>,
pub receipt_timeout: Option<Duration>,
pub dry_run: bool,
pub quiet: bool,
pub allow_custom_endpoints: bool,
}Expand description
Shared invocation context threaded through every subcommand.
Built once in main from parsed global flags; subcommands only read.
Fields§
§api_key: Option<String>§environment: Environment§api_base: Option<String>Explicit --api-base / TASKFAST_API override. Wins over
Environment::api_base when set. Never persisted — the in-memory
override is session-scoped only.
config_path: PathBufResolved path to the JSON config file (default
./.taskfast/config.json, override via --config /
TASKFAST_CONFIG). Subcommands that persist state (init,
config set, etc.) write here; tests construct this directly.
wallet_address: Option<String>Poster wallet address from config — fallback when no flag/env set
on post/settle/escrow sign. Persisted by taskfast init.
keystore_path: Option<PathBuf>Keystore path from config — fallback for the same trio.
confirm_above_budget: Option<String>Stablecoin-units threshold above which mutating commands
(post, settle) require an explicit --yes. None = gate
disabled. Set via confirm_above_budget in the JSON config.
log_format: Option<String>Default log format for --verbose output. None = text. Set
via log_format in the JSON config or TASKFAST_LOG_FORMAT env.
receipt_timeout: Option<Duration>Receipt-polling ceiling for escrow sign. Parsed from the
config file’s receipt_timeout at startup. None = network-aware
default (3min mainnet, 1min testnet). --receipt-timeout /
TASKFAST_RECEIPT_TIMEOUT still win over this.
dry_run: bool§quiet: bool§allow_custom_endpoints: boolF2 opt-in: allow a custom api_base or tempo_rpc_url that isn’t
one of the well-known TaskFast defaults. Plumbed through to
subcommands (notably post) that construct their own network
clients outside the TaskFastClient covered by the Ctx-level
guard.
Implementations§
Source§impl Ctx
impl Ctx
Sourcepub fn from_parts(
cli_api_key: Option<String>,
cli_env: Option<Environment>,
cli_api_base: Option<String>,
cli_config_path: Option<PathBuf>,
cli_dry_run: bool,
cli_quiet: bool,
cli_allow_custom_endpoints: bool,
cfg: &Config,
) -> Result<Self, CmdError>
pub fn from_parts( cli_api_key: Option<String>, cli_env: Option<Environment>, cli_api_base: Option<String>, cli_config_path: Option<PathBuf>, cli_dry_run: bool, cli_quiet: bool, cli_allow_custom_endpoints: bool, cfg: &Config, ) -> Result<Self, CmdError>
Build a Ctx by layering CLI flags (including clap’s
env-var folding) over the on-disk Config. Precedence:
flag > env var > config file > defaultClap already folds flag > env var for each field (via
#[arg(env = "…")]), so the merge here is just “cli wins, else
config, else default”. dry_run and quiet are never
persisted — they’re invocation-scoped.
Sourcepub fn security_warnings(&self) -> Vec<SecurityWarning>
pub fn security_warnings(&self) -> Vec<SecurityWarning>
F15: gather non-fatal security warnings derived from the effective runtime state. Computed at emit time (not at construction) so subcommand-induced signals can be folded in here if needed later. Always safe to call — never allocates for a healthy run.
Sourcepub fn client(&self) -> Result<TaskFastClient, CmdError>
pub fn client(&self) -> Result<TaskFastClient, CmdError>
Build an authenticated client, or fail with CmdError::MissingApiKey
if no key was supplied (via --api-key or TASKFAST_API_KEY).
Sourcepub fn rpc_http_client(&self, client: &TaskFastClient, rpc_url: &str) -> Client
pub fn rpc_http_client(&self, client: &TaskFastClient, rpc_url: &str) -> Client
Pick the reqwest client to use for a JSON-RPC URL.
Any URL whose prefix is {api_base}/rpc/ is this deployment’s
authenticated proxy and must be hit with the X-API-Key-bearing
client; otherwise the proxy short-circuits with 401 “missing API key”
before reaching the upstream RPC. Anything else (a bare upstream
Tempo gateway via --rpc-url/TEMPO_RPC_URL) gets a fresh client
with no TaskFast headers.
This is selected by URL origin (same host as api_base), not by which
resolution branch the URL came from, so a user who points --rpc-url /
TEMPO_RPC_URL at the proxy still gets the authenticated client.
Sourcepub fn enforce_budget_gate(
&self,
budget: Option<&str>,
yes: bool,
verb: &str,
) -> Result<(), CmdError>
pub fn enforce_budget_gate( &self, budget: Option<&str>, yes: bool, verb: &str, ) -> Result<(), CmdError>
Fail-closed budget gate. When confirm_above_budget is set in the
config, any mutation whose budget exceeds it must be opted into via
--yes. By design there’s no TTY prompt — automation-first stays
intact; the gate just stops a fat-finger script before it broadcasts
an oversized ERC-20 approve. verb is the action (“post a task”,
“settle this task”) for the error message.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ctx
impl RefUnwindSafe for Ctx
impl Send for Ctx
impl Sync for Ctx
impl Unpin for Ctx
impl UnsafeUnpin for Ctx
impl UnwindSafe for Ctx
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more