2026-05-25 10:33:29 +01:00
|
|
|
#include <bshell/command/cmdlet.h>
|
|
|
|
|
#include <bshell/command/command.h>
|
|
|
|
|
#include <bshell/status.h>
|
2026-05-24 20:20:06 +01:00
|
|
|
#include <fx/reflection/function.h>
|
|
|
|
|
#include <fx/string.h>
|
|
|
|
|
#include <fx/vector.h>
|
|
|
|
|
|
|
|
|
|
struct bshell_cmdlet_p {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void init(fx_object *obj, void *priv)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static enum bshell_status get_callable_name_static(
|
|
|
|
|
const fx_type *ty,
|
|
|
|
|
fx_string *out)
|
|
|
|
|
{
|
2026-06-13 13:47:16 +01:00
|
|
|
bshell_cmdlet_class *class
|
|
|
|
|
= fx_type_get_interface(ty, BSHELL_TYPE_CMDLET);
|
2026-05-24 20:20:06 +01:00
|
|
|
if (!class) {
|
|
|
|
|
return BSHELL_ERR_NOT_SUPPORTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bshell_verb *verb_info = bshell_verb_get_by_id(class->c_verb);
|
|
|
|
|
if (!verb_info) {
|
|
|
|
|
return BSHELL_ERR_BAD_STATE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fx_string_append_cstrf(
|
|
|
|
|
out,
|
|
|
|
|
"%s-%s",
|
|
|
|
|
bshell_verb_get_name(verb_info),
|
|
|
|
|
class->c_noun);
|
|
|
|
|
return BSHELL_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FX_TYPE_CLASS_BEGIN(bshell_cmdlet)
|
|
|
|
|
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_command, BSHELL_TYPE_COMMAND)
|
|
|
|
|
FX_INTERFACE_ENTRY(c_command_type) = "Cmdlet";
|
|
|
|
|
FX_INTERFACE_ENTRY(c_get_callable_name_static)
|
|
|
|
|
= get_callable_name_static;
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_END(bshell_command, BSHELL_TYPE_COMMAND)
|
|
|
|
|
FX_TYPE_CLASS_END(bshell_cmdlet)
|
|
|
|
|
|
|
|
|
|
FX_TYPE_DEFINITION_BEGIN(bshell_cmdlet)
|
|
|
|
|
FX_TYPE_ID(0xc71f4d59, 0x8066, 0x4294, 0xa6b0, 0xe1f3eb04f454);
|
2026-05-25 10:33:29 +01:00
|
|
|
FX_TYPE_FLAGS(FX_TYPE_F_ABSTRACT);
|
|
|
|
|
FX_TYPE_NAME("bshell.runtime.cmdlet");
|
2026-05-24 20:20:06 +01:00
|
|
|
FX_TYPE_EXTENDS(BSHELL_TYPE_COMMAND);
|
|
|
|
|
FX_TYPE_CLASS(bshell_cmdlet_class);
|
|
|
|
|
FX_TYPE_INSTANCE_INIT(init);
|
|
|
|
|
FX_TYPE_INSTANCE_PRIVATE(struct bshell_cmdlet_p);
|
|
|
|
|
FX_TYPE_DEFINITION_END(bshell_cmdlet)
|