Skip to content

Commit

Permalink
Initial Sys package implementation with interactive shell via MyShell.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Dec 11, 2024
1 parent fc77d84 commit 5c4ae86
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions std/n8std/Sys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
#include "n8std/Sys.hpp"

#include <n8/ast/TerminativeSignal.hpp>
#include <n8/util/RandomUtil.hpp>

#include <cstdlib>
#include <myshell.hpp>

static std::map<std::string, std::shared_ptr<MyShell>> shellMap;

N8_FUNC(sys_quickShell) {
if(args.size() != 1)
Expand All @@ -36,3 +41,18 @@ N8_FUNC(sys_quickShell) {
))
);
}

N8_FUNC(sys_shellConnect) {
if(args.size() != 1)
throw TerminativeThrowSignal(
std::move(address),
"Expecting 1 argument, got " +
std::to_string(args.size())
);

DynamicObject value = args.at(0);
std::string uuid = N8Util::generateUuid();

shellMap[uuid] = std::make_shared<MyShell>(value.toString());
return DynamicObject(uuid);
}
1 change: 1 addition & 0 deletions std/n8std/Sys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ N8_FUNC(sys_shellForceExit);
N8_FUNC(sys_shellHasExited);
N8_FUNC(sys_shellExitCode);
N8_FUNC(sys_shellProcessId);
N8_FUNC(sys_shellClose);

N8_LIB_END

Expand Down

0 comments on commit 5c4ae86

Please sign in to comment.