You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/11/04 02:53:35 UTC

[GitHub] [apisix] spacewander commented on a change in pull request #2612: improve: refactor partial command line tool.

spacewander commented on a change in pull request #2612:
URL: https://github.com/apache/apisix/pull/2612#discussion_r517069309



##########
File path: apisix/cli/util.lua
##########
@@ -0,0 +1,49 @@
+--
+-- 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.
+--
+
+local popen = io.popen
+
+local _M = {}
+
+
+-- Note: The `execute_cmd` return value will have a line break at the end,
+-- it is recommended to use the `trim` function to handle the return value.
+function _M.execute_cmd(cmd)
+    local t, err = popen(cmd)
+    if not t then
+        return nil, "failed to execute command: "
+                    .. cmd .. ", error info: " .. err
+    end
+
+    local data, err = t:read("*all")
+    if err ~= nil then

Review comment:
       Should always close `t` even error happened.

##########
File path: bin/apisix
##########
@@ -346,8 +285,8 @@ end
 
 local checked_admin_key = false
 local function init()
-    if is_root_path then
-        print('Warning! Running apisix under /root is only suitable for development environments'
+    if env.is_root_path then
+        print('Warning! Running apisix under /root is only suitable for development envments'

Review comment:
       Why use `envments`?




----------------------------------------------------------------
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