From 41f19f8dc9949269e1fc10531890d27e3ea73c8f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 7 Apr 2019 09:43:40 +1000 Subject: Add support for %file{...} expansions This should make the use case exposed in #2836 implementable. --- src/command_manager.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/command_manager.cc') diff --git a/src/command_manager.cc b/src/command_manager.cc index f777eeda..5e8c8196 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -5,6 +5,7 @@ #include "buffer_utils.hh" #include "context.hh" #include "flags.hh" +#include "file.hh" #include "optional.hh" #include "option_types.hh" #include "ranges.hh" @@ -168,6 +169,8 @@ Token::Type token_type(StringView type_name, bool throw_on_invalid) return Token::Type::ValExpand; else if (type_name == "arg") return Token::Type::ArgExpand; + else if (type_name == "file") + return Token::Type::FileExpand; else if (throw_on_invalid) throw parse_error{format("unknown expand '{}'", type_name)}; else @@ -327,6 +330,8 @@ expand_token(const Token& token, const Context& context, const ShellContext& she throw runtime_error("invalid argument index"); return {arg < params.size() ? params[arg] : String{}}; } + case Token::Type::FileExpand: + return {read_file(content)}; case Token::Type::RawEval: return {expand(content, context, shell_context)}; case Token::Type::Raw: -- cgit v1.2.3