Shell: rewrite the whole shell to use tokens instead of raw strings

tab completion is still running with raw strings and that has to be
fixed in the future.
This commit is contained in:
2024-10-13 21:56:59 +03:00
parent dab6e5a60f
commit 8adc97980a
18 changed files with 2721 additions and 1732 deletions

View File

@@ -0,0 +1,31 @@
#pragma once
#include <BAN/Function.h>
#include <BAN/HashMap.h>
#include <BAN/Iteration.h>
#include <BAN/NoCopyMove.h>
#include <BAN/String.h>
class Alias
{
BAN_NON_COPYABLE(Alias);
BAN_NON_MOVABLE(Alias);
public:
Alias() = default;
static Alias& get()
{
static Alias s_instance;
return s_instance;
}
BAN::ErrorOr<void> set_alias(BAN::StringView name, BAN::StringView value);
// NOTE: `const BAN::String&` instead of `BAN::StringView` to avoid BAN::String construction
// for hashmap accesses
BAN::Optional<BAN::StringView> get_alias(const BAN::String& name) const;
void for_each_alias(BAN::Function<BAN::Iteration(BAN::StringView, BAN::StringView)>) const;
private:
BAN::HashMap<BAN::String, BAN::String> m_aliases;
};