pub struct Ctx<'a> {
pub platform: &'a dyn Platform,
pub out: &'a mut dyn Write,
pub err: &'a mut dyn Write,
pub input: &'a mut dyn BufRead,
pub globals: Globals,
/* private fields */
}Expand description
A run: the platform, the outputs and the configuration, read only when a command needs it.
Fields§
§platform: &'a dyn Platform§out: &'a mut dyn Write§err: &'a mut dyn Write§input: &'a mut dyn BufRead§globals: GlobalsImplementations§
Source§impl<'a> Ctx<'a>
impl<'a> Ctx<'a>
pub fn new( platform: &'a dyn Platform, out: &'a mut dyn Write, err: &'a mut dyn Write, input: &'a mut dyn BufRead, globals: Globals, ) -> Ctx<'a>
pub fn env(&self, name: &str) -> Option<String>
Sourcepub fn config_path(&self) -> Result<PathBuf, CliError>
pub fn config_path(&self) -> Result<PathBuf, CliError>
The path of config.yml.
Sourcepub fn select_profile(&mut self, name: Option<String>)
pub fn select_profile(&mut self, name: Option<String>)
Makes name the profile the next calls use, as --profile would.
Sourcepub fn load_config(&self) -> Result<ConfigFile, CliError>
pub fn load_config(&self) -> Result<ConfigFile, CliError>
The profiles file (empty if it does not exist yet).
pub fn save_config(&self, file: &ConfigFile) -> Result<(), CliError>
Sourcepub fn settings(&mut self) -> Result<&Effective, CliError>
pub fn settings(&mut self) -> Result<&Effective, CliError>
The effective configuration: variables, chosen profile and built-in values.
Sourcepub fn json_chosen(&mut self) -> bool
pub fn json_chosen(&mut self) -> bool
true when the person chose json (on the command line, in the environment or in the profile), and not
when it is only the built-in value: only then does the error come out as the server’s ErrorResponse.
pub fn format(&mut self) -> Result<Format, CliError>
Sourcepub fn api_client(&mut self) -> Result<Client, CliError>
pub fn api_client(&mut self) -> Result<Client, CliError>
The client API client (with the profile’s token).
Sourcepub fn ops_client(&mut self, attempts: Option<u32>) -> Result<Client, CliError>
pub fn ops_client(&mut self, attempts: Option<u32>) -> Result<Client, CliError>
The operations API client: no token. attempts overrides the profile’s max-attempts.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Ctx<'a>
impl<'a> !Send for Ctx<'a>
impl<'a> !Sync for Ctx<'a>
impl<'a> !UnwindSafe for Ctx<'a>
impl<'a> Freeze for Ctx<'a>
impl<'a> Unpin for Ctx<'a>
impl<'a> UnsafeUnpin for Ctx<'a>
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
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> ⓘ
Converts
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> ⓘ
Converts
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