[k2] add support argc/argv superglobals in k2-cli #1295
[k2] add support argc/argv superglobals in k2-cli #1295astrophysik wants to merge 4 commits intomasterfrom
Conversation
| } else if (letter == '"') { | ||
| in_quote = !in_quote; | ||
| } else if (letter == '\'') { | ||
| php_warning("in command line arg supported only \" quote"); |
There was a problem hiding this comment.
i think you added an extra space \" quote"
|
|
||
| if (G->is_output_mode_k2()) { | ||
| W << "namespace kphp::compiler_interface {" << NL; | ||
| FunctionSignatureGenerator(W) << ("std::string_view get_main_file_name() ") << BEGIN; |
There was a problem hiding this comment.
let's make this function constexpr
There was a problem hiding this comment.
clang++ gives error with message that inline function ... is not defined
There was a problem hiding this comment.
please, considering using - instead of _ in file names
|
|
||
| private: | ||
| static constexpr std::string_view INI_ARG_PREFIX = "ini "; | ||
| static constexpr std::string_view COMMAND_LINE_ARG = "command-line"; |
There was a problem hiding this comment.
let's define it as CLI_ARG = "cli"
| const uint32_t argc; | ||
| const uint32_t envc; | ||
| mixed runtime_config; | ||
| array<string> command_line_argv; |
| } | ||
|
|
||
| void ComponentState::parse_command_line_arg(std::string_view value_view) noexcept { | ||
| if (value_view.empty()) [[unlikely]] { |
There was a problem hiding this comment.
I don't think we need to have warning here
| return; | ||
| } | ||
|
|
||
| if (!command_line_argv.empty()) [[unlikely]] { |
There was a problem hiding this comment.
This check should be placed at the top of the function
| } | ||
|
|
||
| if (!command_line_argv.empty()) [[unlikely]] { | ||
| php_warning("command line argument support no more one usage"); |
There was a problem hiding this comment.
weird message, I'd suggest multiple command line arguments strings specified. skipping or something similar
| return; | ||
| } | ||
|
|
||
| const auto& main_file_view{kphp::compiler_interface::get_main_file_name()}; |
There was a problem hiding this comment.
I think reference is redundant here
| command_line_argv.push_back(string(main_file_view.data(), main_file_view.size())); | ||
|
|
||
| bool in_quote{}; | ||
| string current_arg{}; |
There was a problem hiding this comment.
It seems like an error. You need to set special reference counter for each reference counted object
|
|
||
| bool in_quote{}; | ||
| string current_arg{}; | ||
| for (char letter : value_view) { |
There was a problem hiding this comment.
It's not actually letter since there might be other symbols
| bool in_quote{}; | ||
| string current_arg{}; | ||
| for (char letter : value_view) { | ||
| if (std::isspace(letter) && !in_quote && !current_arg.empty()) { |
There was a problem hiding this comment.
Looks overcomplicated. Let's use standard string view functions instead
No description provided.