Commit b0ea2410 authored by jan.koester's avatar jan.koester
Browse files

blogi: report a missing config instead of exiting silently with 255

parseCmd stops at the first unknown option, so e.g. "-f True -c ..." never
read -c and main returned -1 without a word. Print an error plus the help
text, and accept -F with true/True/1/yes or no value at all.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 99b6fdf7
Loading
Loading
Loading
Loading
+9 −1
Changes for src/blogi.cpp: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -4294,13 +4294,21 @@ int main(int argc, char *argv[])

    bool fground = false;

    if (BlogiCmdCtl.getCmdbyKey("foreground")->getValue() == "true")
    {
        cmdplus::Cmd *fg = BlogiCmdCtl.getCmdbyKey("foreground");
        std::string fgval = fg->getValue();
        for (auto &ch : fgval)
            ch = (char)std::tolower((unsigned char)ch);
        if (fgval == "true" || fgval == "1" || fgval == "yes" || (fg->getFound() && fgval.empty()))
        {
            fground = true;
        }
    }

    if (config.empty())
    {
        std::cerr << "blogi: no config given (use -c <file> / --config <file>; foreground is -F true)" << std::endl;
        BlogiCmdCtl.printHelp();
        return -1;
    }