[][src]Struct libimagrt::runtime::Runtime

pub struct Runtime<'a> { /* fields omitted */ }

The Runtime object

This object contains the complete runtime environment of the imag application running.

Methods

impl<'a> Runtime<'a>[src]

pub fn new<C>(cli_app: C) -> Result<Runtime<'a>> where
    C: Clone + CliSpec<'a> + InternalConfiguration
[src]

Gets the CLI spec for the program and retreives the config file path (or uses the default on in $HOME/.imag/config, $XDG_CONFIG_DIR/imag/config or from env("$IMAG_CONFIG") and builds the Runtime object with it.

The cli_app object should be initially build with the ::get_default_cli_builder() function.

pub fn with_configuration<C>(
    cli_app: C,
    config: Option<Value>
) -> Result<Runtime<'a>> where
    C: Clone + CliSpec<'a> + InternalConfiguration
[src]

Builds the Runtime object using the given config.

pub fn get_default_cli_builder(
    appname: &'a str,
    version: &'a str,
    about: &'a str
) -> App<'a, 'a>
[src]

Get a commandline-interface builder object from clap

This commandline interface builder object already contains some predefined interface flags:

  • -v | --verbose for verbosity
  • --debug for debugging
  • -c | --config for alternative configuration file
  • -r | --rtp for alternative runtimepath
  • --store for alternative store path Each has the appropriate help text included.

The appname shall be "imag-".

pub fn is_verbose(&self) -> bool[src]

Get the verbosity flag value

pub fn is_debugging(&self) -> bool[src]

Get the debugging flag value

pub fn rtp(&self) -> &PathBuf[src]

Get the runtimepath

pub fn cli(&self) -> &ArgMatches[src]

Get the commandline interface matches

pub fn ids<T: IdPathProvider>(&self) -> Result<Option<Vec<StoreId>>>[src]

pub fn config(&self) -> Option<&Value>[src]

Get the configuration object

pub fn store(&self) -> &Store[src]

Get the store object

pub fn editor(&self) -> Result<Option<Command>>[src]

Get a editor command object which can be called to open the $EDITOR

pub fn output_is_pipe(&self) -> bool[src]

pub fn input_is_pipe(&self) -> bool[src]

pub fn ids_from_stdin(&self) -> bool[src]

Alias for Runtime::input_is_pipe()

pub fn ignore_ids(&self) -> bool[src]

Check whether the runtime ignores touched ids

"Ignoring" in this context means whether the runtime prints them or not.

Important traits for OutputProxy
pub fn stdout(&self) -> OutputProxy[src]

Important traits for OutputProxy
pub fn stderr(&self) -> OutputProxy[src]

pub fn stdin(&self) -> Option<Stdin>[src]

pub fn handle_unknown_subcommand<S: AsRef<str>>(
    &self,
    command: S,
    subcommand: S,
    args: &ArgMatches
) -> Result<ExitStatus>
[src]

Helper for handling subcommands which are not available.

Example

For example someone calls imag foo bar. If imag-foo is in the $PATH, but it has no subcommand bar, the imag-foo binary is able to automatically forward the invokation to a imag-foo-bar binary which might be in $PATH.

It needs to call Runtime::handle_unknown_subcommand with the following parameters:

  1. The "command" which was issued. In the example this would be "imag-foo"
  2. The "subcommand" which is missing: "bar" in the example
  3. The ArgMatches object from the call, so that this routine can forward all flags passed to the bar subcommand.

Warning

If, and only if, the subcommand does not exist (as in ::std::io::ErrorKind::NotFound), this function exits with 1 as exit status.

Return value

On success, the exit status object of the Command invocation is returned.

Details

The IMAG_RTP variable is set for the child process. It is set to the current runtime path.

Stdin, stdout and stderr are inherited to the child process.

This function blocks until the child returns.

pub fn report_touched(&self, id: &StoreId) -> Result<()>[src]

pub fn report_all_touched<ID, I>(&self, ids: I) -> Result<()> where
    ID: Borrow<StoreId> + Sized,
    I: Iterator<Item = ID>, 
[src]

Trait Implementations

impl<'a> Debug for Runtime<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Runtime<'a>

impl<'a> !Send for Runtime<'a>

impl<'a> !Sync for Runtime<'a>

impl<'a> Unpin for Runtime<'a>

impl<'a> !UnwindSafe for Runtime<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,