fgerlits commented on code in PR #1638:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1638#discussion_r1327179105
##########
controller/MiNiFiController.cpp:
##########
@@ -106,81 +109,108 @@ int main(int argc, char **argv) {
socket_data.ssl_context_service = getSSLContextService(configuration);
} catch(const minifi::Exception& ex) {
logger->log_error(ex.what());
- exit(1);
+ std::exit(1);
}
- cxxopts::Options options("MiNiFiController", "MiNiFi local agent
controller");
- options.positional_help("[optional args]").show_positional_help();
-
- options.add_options()
- ("h,help", "Shows Help")
- ("host", "Specifies connecting host name", cxxopts::value<std::string>())
- ("port", "Specifies connecting host port", cxxopts::value<int>())
- ("stop", "Shuts down the provided component",
cxxopts::value<std::vector<std::string>>())
- ("start", "Starts provided component",
cxxopts::value<std::vector<std::string>>())
- ("l,list", "Provides a list of connections or processors",
cxxopts::value<std::string>())
- ("c,clear", "Clears the associated connection queue",
cxxopts::value<std::vector<std::string>>())
- ("getsize", "Reports the size of the associated connection queue",
cxxopts::value<std::vector<std::string>>())
- ("updateflow", "Updates the flow of the agent using the provided flow
file", cxxopts::value<std::string>())
- ("getfull", "Reports a list of full connections")
- ("jstack", "Returns backtraces from the agent")
- ("manifest", "Generates a manifest for the current binary")
- ("noheaders", "Removes headers from output streams");
+ argparse::ArgumentParser argument_parser("Apache MiNiFi C++ Controller",
minifi::AgentBuild::VERSION);
+ argument_parser.add_argument("--host").metavar("HOSTNAME")
+ .help("Specifies connecting host name");
+ argument_parser.add_argument("--port")
+ .metavar("PORT")
+ .help("Specifies connecting host port")
+ .scan<'d', int>();
+ argument_parser.add_argument("--stop")
+ .metavar("COMPONENT")
+ .nargs(argparse::nargs_pattern::at_least_one)
+ .help("Shuts down the provided components");
+ argument_parser.add_argument("--start")
+ .metavar("COMPONENT")
+ .nargs(argparse::nargs_pattern::at_least_one)
+ .help("Starts provided components");
+ argument_parser.add_argument("-l", "--list")
+ .action([](const std::string& value) {
+ static const std::vector<std::string> choices = {"components",
"connections"};
+ if (ranges::contains(choices, value)) {
+ return value;
+ }
Review Comment:
Very minor, but this is shorter and cheaper:
```suggestion
if (ranges::contains(std::array{"components", "connections"}, value)) {
return value;
}
```
##########
LICENSE:
##########
@@ -1250,60 +1250,6 @@ Redistribution and use in source and binary forms, with
or without modification,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-This product bundles 'cxxopts' which is available under an MIT license.
-
-Copyright (c) 2014 Jarryd Beck
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-This product bundles zlib which is available under the zlib license:
-
- (C) 1995-2017 Jean-loup Gailly and Mark Adler
Review Comment:
I don't think this should be deleted, since we still bundle `zlib`
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]