Skip to content

Commit aaa022f

Browse files
committed
feat(terminal): 添加AddDirNode()快捷函数
1 parent 5ca3587 commit aaa022f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

modules/terminal/helper.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@
2626
namespace tbox {
2727
namespace terminal {
2828

29+
NodeToken AddDirNode(TerminalNodes &terminal, NodeToken parent_node,
30+
const std::string &name, const std::string &help)
31+
{
32+
auto dir_node = terminal.createDirNode(help);
33+
if (terminal.mountNode(parent_node, dir_node, name))
34+
return dir_node;
35+
36+
terminal.deleteNode(dir_node);
37+
return NodeToken();
38+
}
39+
2940
NodeToken AddFuncNode(TerminalNodes &terminal, NodeToken parent_node,
3041
const std::string &name, VoidFunc &&func)
3142
{

modules/terminal/helper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
namespace tbox {
2929
namespace terminal {
3030

31+
//! 添加目标结点
32+
NodeToken AddDirNode(TerminalNodes &terminal, NodeToken parent_node,
33+
const std::string &name, const std::string &help = "");
34+
3135
//! 添加Boolean变量读写结点
3236
NodeToken AddFuncNode(TerminalNodes &terminal, NodeToken parent_node,
3337
const std::string &name, bool &value);

0 commit comments

Comments
 (0)