celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [celix] pnoltes commented on a change in pull request #310: Adds initial impl for the C++ headers only wrappers
Date Sun, 21 Feb 2021 16:18:06 GMT

pnoltes commented on a change in pull request #310:
URL: https://github.com/apache/celix/pull/310#discussion_r579829613



##########
File path: bundles/shell/shell/src/Shell.cc
##########
@@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <memory>
+#include <unordered_map>
+
+#include "celix/BundleActivator.h"
+#include "celix/IShellCommand.h"
+#include "std_commands.h"
+#include "celix_shell_command.h"
+#include "celix_log_service.h"
+#include "celix_shell_command.h"
+#include "celix_shell.h"
+
+namespace celix {
+
+    class Shell {
+    public:
+
+        /**
+         * Try to execute a command using the provided command line.
+         */
+        celix_status_t executeCommand(const char *commandLine, FILE *out, FILE *err) {
+            std::vector<std::string> tokens = tokenize(commandLine);
+            if (tokens.empty()) {
+                fprintf(err, "Invalid commandLine '%s'\n", commandLine);
+                return CELIX_ILLEGAL_ARGUMENT;
+            }
+
+            Entry entry = findCommand(tokens[0], err);
+            if (entry.cCommand) {
+                 bool successful = entry.cCommand->executeCommand(entry.cCommand->handle,
commandLine, out, err);
+                 return successful ? CELIX_SUCCESS : CELIX_SERVICE_EXCEPTION;
+            } else if (entry.cxxCommand) {
+                std::vector<std::string> arguments{};
+                auto start = ++tokens.begin();
+                arguments.insert(arguments.begin(), start, tokens.end());
+                entry.cxxCommand->executeCommand(commandLine, arguments, out, err);

Review comment:
       Agree, this has been updated




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message