diff options
author | Daniel Mueller <deso@posteo.net> | 2019-01-06 16:59:11 -0800 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2019-01-06 16:59:11 -0800 |
commit | e78d0432b8db215cf76cb410de354287fc2da8ba (patch) | |
tree | 1c8e160868d7749b44f66e317848170947b28249 /nitrocli/src/error.rs | |
parent | 6bb629b4d1035c3fd851244060f99da78a7bd929 (diff) | |
download | nitrocli-e78d0432b8db215cf76cb410de354287fc2da8ba.tar.gz nitrocli-e78d0432b8db215cf76cb410de354287fc2da8ba.tar.bz2 |
Introduce support for user-provided extensions
This change introduces support for discovering and executing
user-provided extensions to the program. Extensions are useful for
allowing users to provide additional functionality on top of the
nitrocli proper. Implementation wise we stick to an approach similar to
git or cargo subcommands in nature: we find executables in the PATH
environment variable whose file name starts with "nitrocli-" and allow
for them to be invoked as a nitrocli command.
Diffstat (limited to 'nitrocli/src/error.rs')
-rw-r--r-- | nitrocli/src/error.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nitrocli/src/error.rs b/nitrocli/src/error.rs index 819bed8..1f6424e 100644 --- a/nitrocli/src/error.rs +++ b/nitrocli/src/error.rs @@ -45,6 +45,7 @@ pub enum Error { NitrokeyError(Option<&'static str>, nitrokey::Error), Utf8Error(str::Utf8Error), Error(String), + ExtensionFailed(String, Option<i32>), } impl TryInto<nitrokey::Error> for Error { @@ -99,6 +100,13 @@ impl fmt::Display for Error { Error::Utf8Error(_) => write!(f, "Encountered UTF-8 conversion error"), Error::IoError(ref e) => write!(f, "IO error: {}", e), Error::Error(ref e) => write!(f, "{}", e), + Error::ExtensionFailed(ref ext, rc) => { + write!(f, "Extension {} failed", ext)?; + if let Some(rc) = rc { + write!(f, " with exit code {}", rc)?; + } + Ok(()) + } } } } |