From 62509c100c876b6d427673709a530c481ec7e4c0 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Tue, 25 Aug 2020 19:04:50 -0700 Subject: 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 search the directories listed in the PATH environment variable for a file that starts with "nitrocli-", followed by the extension name. This file is then executed. It is assumed that the extension recognizes (or at least not prohibits) the following arguments: --nitrocli (providing the path to the nitrocli binary), --model (with the model passed to the main program), and --verbosity (the verbosity level). --- src/args.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index 6cf37c8..a8f43e1 100644 --- a/src/args.rs +++ b/src/args.rs @@ -4,6 +4,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later use std::convert; +use std::ffi; /// Provides access to a Nitrokey device #[derive(Debug, structopt::StructOpt)] @@ -107,6 +108,9 @@ Command! { Status => crate::commands::status, /// Interacts with the device's unencrypted volume Unencrypted(UnencryptedArgs) => |ctx, args: UnencryptedArgs| args.subcmd.execute(ctx), + /// An extension and its arguments. + #[structopt(external_subcommand)] + Extension(Vec) => crate::commands::extension, ] } -- cgit v1.2.1