2012-05-03 09:25:13 +02:00
|
|
|
#ifndef shell_manager_hh_INCLUDED
|
|
|
|
#define shell_manager_hh_INCLUDED
|
|
|
|
|
2015-03-09 14:48:41 +01:00
|
|
|
#include "array_view.hh"
|
2014-04-07 22:25:44 +02:00
|
|
|
#include "env_vars.hh"
|
2015-06-08 14:34:08 +02:00
|
|
|
#include "flags.hh"
|
2015-09-03 14:53:17 +02:00
|
|
|
#include "string.hh"
|
|
|
|
#include "utils.hh"
|
2012-05-03 09:25:13 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2014-01-27 21:28:38 +01:00
|
|
|
class Context;
|
2014-11-12 22:27:07 +01:00
|
|
|
|
2014-04-20 13:15:31 +02:00
|
|
|
using EnvVarRetriever = std::function<String (StringView name, const Context&)>;
|
2012-05-03 09:25:13 +02:00
|
|
|
|
|
|
|
class ShellManager : public Singleton<ShellManager>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShellManager();
|
|
|
|
|
2015-06-08 14:34:08 +02:00
|
|
|
enum class Flags
|
|
|
|
{
|
|
|
|
None = 0,
|
2015-06-08 23:42:51 +02:00
|
|
|
WaitForStdout = 1
|
2015-06-08 14:34:08 +02:00
|
|
|
};
|
|
|
|
|
2015-03-13 14:39:18 +01:00
|
|
|
std::pair<String, int> eval(StringView cmdline, const Context& context,
|
|
|
|
StringView input = {},
|
2015-06-08 23:42:51 +02:00
|
|
|
Flags flags = Flags::WaitForStdout,
|
2015-03-13 14:39:18 +01:00
|
|
|
ConstArrayView<String> params = {},
|
|
|
|
const EnvVarMap& env_vars = EnvVarMap{});
|
2012-05-29 12:39:03 +02:00
|
|
|
|
2015-09-03 14:21:35 +02:00
|
|
|
void register_env_var(StringView str, bool prefix, EnvVarRetriever retriever);
|
2014-06-18 20:28:48 +02:00
|
|
|
String get_val(StringView name, const Context& context) const;
|
2012-05-03 09:25:13 +02:00
|
|
|
|
|
|
|
private:
|
2015-09-03 14:21:35 +02:00
|
|
|
struct EnvVarDesc { String str; bool prefix; EnvVarRetriever func; };
|
|
|
|
Vector<EnvVarDesc> m_env_vars;
|
2012-05-03 09:25:13 +02:00
|
|
|
};
|
|
|
|
|
2015-06-08 14:34:08 +02:00
|
|
|
template<> struct WithBitOps<ShellManager::Flags> : std::true_type {};
|
|
|
|
|
2012-05-03 09:25:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // shell_manager_hh_INCLUDED
|