Struct quartz_cli::Ctx
source · pub struct Ctx {
pub args: CtxArgs,
pub config: Config,
pub state: State,
/* private fields */
}
Fields§
§args: CtxArgs
§config: Config
§state: State
Implementations§
source§impl Ctx
impl Ctx
pub fn new(args: CtxArgs) -> QuartzResult<Self>
pub fn require_input_handle(&self, handle: &str) -> EndpointHandle
pub fn require_handle(&self) -> EndpointHandle
pub fn require_endpoint(&self) -> (EndpointHandle, Endpoint)
pub fn require_endpoint_from_handle(&self, handle: &EndpointHandle) -> Endpoint
sourcepub fn require_env(&self) -> Env
pub fn require_env(&self) -> Env
sourcepub fn edit<F>(&self, path: &Path, validate: F) -> QuartzResult
pub fn edit<F>(&self, path: &Path, validate: F) -> QuartzResult
Opens an editor to modified the specified file at path
in a temporary file.
After the program exits, validate
function is ran on temporary file before moving it to
the original file, effectively commiting the edits.
If validate
returns Err
, the temporary file is deleted while original file is preserved as is.
§Arguments
path
- A path slice to a filevalidate
- Validator method to ensure the edit can be saved without errors
sourcepub fn edit_with_extension<F>(
&self,
path: &Path,
extension: Option<&str>,
validate: F
) -> QuartzResult
pub fn edit_with_extension<F>( &self, path: &Path, extension: Option<&str>, validate: F ) -> QuartzResult
Opens an editor to modified the specified file at path
with extension
in a temporary file.
After the program exits, validate
function is ran on temporary file before moving it to
the original file, effectively commiting the edits.
If validate
returns Err
, the temporary file is deleted while original file is preserved as is.
§Arguments
path
- A path slice to a fileextension
- Which extension to create temporary file withvalidate
- Validator method to ensure the edit can be saved without errors
sourcepub fn paginate(&self, input: &[u8]) -> QuartzResult
pub fn paginate(&self, input: &[u8]) -> QuartzResult
Open user’s preferred pager with content.
pub fn user_agent() -> String
pub fn path(&self) -> &Path
pub fn code(&mut self, value: ExitCode)
pub fn confirm(&self, message: &str) -> bool
pub fn exit_code(&self) -> &ExitCode
Auto Trait Implementations§
impl Freeze for Ctx
impl RefUnwindSafe for Ctx
impl Send for Ctx
impl Sync for Ctx
impl Unpin 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
Mutably borrows from an owned value. Read more