diff options
author | Li Jin <dragon-fly@qq.com> | 2021-08-10 16:50:00 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-08-10 16:50:00 +0800 |
commit | 2511572a2c9f9cc8c79fa42163717ed840767545 (patch) | |
tree | 9109bf58274af82307a2bfe63b1b136f37f55ebf | |
parent | 68205aae89b1fe5f970fe4a8e722a1d1cecd266b (diff) | |
download | yuescript-2511572a2c9f9cc8c79fa42163717ed840767545.tar.gz yuescript-2511572a2c9f9cc8c79fa42163717ed840767545.tar.bz2 yuescript-2511572a2c9f9cc8c79fa42163717ed840767545.zip |
support passing comand line argument in another way.
-rw-r--r-- | src/yue.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/yue.cpp b/src/yue.cpp index bf0ac24..f891ebe 100644 --- a/src/yue.cpp +++ b/src/yue.cpp | |||
@@ -160,9 +160,7 @@ int main(int narg, const char** args) { | |||
160 | completions.push_back(pre + "local "); | 160 | completions.push_back(pre + "local "); |
161 | break; | 161 | break; |
162 | case 'm': | 162 | case 'm': |
163 | completions.push_back(pre + "macro expr "); | 163 | completions.push_back(pre + "macro "); |
164 | completions.push_back(pre + "macro block "); | ||
165 | completions.push_back(pre + "macro lua "); | ||
166 | break; | 164 | break; |
167 | case 's': | 165 | case 's': |
168 | completions.push_back(pre + "switch "); | 166 | completions.push_back(pre + "switch "); |
@@ -385,12 +383,19 @@ int main(int narg, const char** args) { | |||
385 | std::cout << help; | 383 | std::cout << help; |
386 | return 1; | 384 | return 1; |
387 | } | 385 | } |
388 | } else if (arg.substr(0, 1) == "-"sv && arg.find('=') != std::string::npos) { | 386 | } else if (arg.size() > 1 && arg.substr(0, 1) == "-"sv && arg.substr(1, 1) != "-"sv) { |
389 | auto argStr = arg.substr(1); | 387 | auto argStr = arg.substr(1); |
388 | yue::Utils::trim(argStr); | ||
390 | size_t idx = argStr.find('='); | 389 | size_t idx = argStr.find('='); |
391 | auto key = argStr.substr(0, idx); | 390 | if (idx != std::string::npos) { |
392 | auto value = argStr.substr(idx + 1); | 391 | auto key = argStr.substr(0, idx); |
393 | config.options[key] = value; | 392 | auto value = argStr.substr(idx + 1); |
393 | yue::Utils::trim(key); | ||
394 | yue::Utils::trim(value); | ||
395 | config.options[key] = value; | ||
396 | } else { | ||
397 | config.options[argStr] = '1'; | ||
398 | } | ||
394 | } else { | 399 | } else { |
395 | if (fs::is_directory(arg)) { | 400 | if (fs::is_directory(arg)) { |
396 | for (auto item : fs::recursive_directory_iterator(arg)) { | 401 | for (auto item : fs::recursive_directory_iterator(arg)) { |