| 797 | } |
| 798 | |
| 799 | bool CommandLineInterface::parseArguments(int _argc, char const* const* _argv) |
| 800 | { |
| 801 | CommandLineParser parser; |
| 802 | |
| 803 | if (isatty(fileno(stdin)) && _argc == 1) |
| 804 | { |
| 805 | // If the terminal is taking input from the user, provide more user-friendly output. |
| 806 | CommandLineParser::printHelp(sout()); |
| 807 | |
| 808 | // In this case we want to exit with an error but not display any error message. |
| 809 | return false; |
| 810 | } |
| 811 | |
| 812 | try |
| 813 | { |
| 814 | parser.parse(_argc, _argv); |
| 815 | } |
| 816 | catch (...) |
| 817 | { |
| 818 | // Even if the overall CLI parsing fails, the --color/--no-color options may have been |
| 819 | // successfully parsed, and if so, should be taken into account when printing errors. |
| 820 | // If no value is present, it's possible that --no-color is still there but parsing failed |
| 821 | // due to other, unrecognized options so play it safe and disable color in that case. |
| 822 | m_options.formatting.coloredOutput = parser.options().formatting.coloredOutput.value_or(false); |
| 823 | throw; |
| 824 | } |
| 825 | m_options = parser.options(); |
| 826 | |
| 827 | return true; |
| 828 | } |
| 829 | |
| 830 | void CommandLineInterface::processInput() |
| 831 | { |
no test coverage detected