alias: implement a set of builtin aliases

This commit is contained in:
2026-05-24 20:22:30 +01:00
parent 0ee1a3575d
commit f772f4ba20
2 changed files with 90 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
#include "../command/alias.h"
#include "../command/command.h"
#include <fx/reflection/function.h>
#include <fx/string.h>
#include <fx/vector.h>
#define BSHELL_TYPE_ECHO (bshell_echo_get_type())
fx_type_id bshell_echo_get_type(void);
FX_DECLARE_TYPE(bshell_echo);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_echo)
FX_TYPE_CLASS_DECLARATION_END(bshell_echo)
struct bshell_echo_p {
};
static void init(fx_object *obj, void *priv)
{
}
FX_TYPE_CLASS_BEGIN(bshell_echo)
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_INTERFACE_ENTRY(to_string) = NULL;
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
FX_TYPE_VTABLE_INTERFACE_BEGIN(bshell_alias, BSHELL_TYPE_ALIAS)
FX_INTERFACE_ENTRY(a_callable_name) = "echo";
FX_INTERFACE_ENTRY(a_target_name) = "Write-Output";
FX_TYPE_VTABLE_INTERFACE_END(bshell_cmdlet, BSHELL_TYPE_CMDLET)
FX_TYPE_VTABLE_INTERFACE_BEGIN(bshell_command, BSHELL_TYPE_COMMAND)
FX_TYPE_VTABLE_INTERFACE_END(bshell_command, BSHELL_TYPE_COMMAND)
FX_TYPE_CLASS_END(bshell_echo)
FX_TYPE_DEFINITION_BEGIN(bshell_echo)
FX_TYPE_ID(0xedd507bf, 0x2e32, 0x425b, 0x9c73, 0x2ba9539eace0);
FX_TYPE_NAME("bshell.core.echo");
FX_TYPE_EXTENDS(BSHELL_TYPE_ALIAS);
FX_TYPE_CLASS(bshell_echo_class);
FX_TYPE_INSTANCE_INIT(init);
FX_TYPE_INSTANCE_PRIVATE(struct bshell_echo_p);
FX_TYPE_DEFINITION_END(bshell_echo)
+45
View File
@@ -0,0 +1,45 @@
#include "../command/alias.h"
#include "../command/command.h"
#include <fx/reflection/function.h>
#include <fx/string.h>
#include <fx/vector.h>
#define BSHELL_TYPE_PERCENT (bshell_percent_get_type())
fx_type_id bshell_percent_get_type(void);
FX_DECLARE_TYPE(bshell_percent);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_percent)
FX_TYPE_CLASS_DECLARATION_END(bshell_percent)
struct bshell_percent_p {
};
static void init(fx_object *obj, void *priv)
{
}
FX_TYPE_CLASS_BEGIN(bshell_percent)
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_INTERFACE_ENTRY(to_string) = NULL;
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
FX_TYPE_VTABLE_INTERFACE_BEGIN(bshell_alias, BSHELL_TYPE_ALIAS)
FX_INTERFACE_ENTRY(a_callable_name) = "%";
FX_INTERFACE_ENTRY(a_target_name) = "ForEach-Object";
FX_TYPE_VTABLE_INTERFACE_END(bshell_cmdlet, BSHELL_TYPE_CMDLET)
FX_TYPE_VTABLE_INTERFACE_BEGIN(bshell_command, BSHELL_TYPE_COMMAND)
FX_TYPE_VTABLE_INTERFACE_END(bshell_command, BSHELL_TYPE_COMMAND)
FX_TYPE_CLASS_END(bshell_percent)
FX_TYPE_DEFINITION_BEGIN(bshell_percent)
FX_TYPE_ID(0x4255a9de, 0xd6f6, 0x4708, 0x829c, 0xffa4c6034edb);
FX_TYPE_NAME("bshell.core.percent");
FX_TYPE_EXTENDS(BSHELL_TYPE_ALIAS);
FX_TYPE_CLASS(bshell_percent_class);
FX_TYPE_INSTANCE_INIT(init);
FX_TYPE_INSTANCE_PRIVATE(struct bshell_percent_p);
FX_TYPE_DEFINITION_END(bshell_percent)