Files
slocker-lite/src/self_test.cpp
T
ceamac 0f43a02bd7 Split main.cpp into cli_args, commands, and self_test
main.cpp had grown to ~910 lines holding CLI parsing, every command
implementation, and the -t/--test handler all in one file. Split it:

- cli_args.{h,cpp}: getopt_long parsing and all post-loop validation
  (parse_args()), producing a ParsedArgs the rest of the program consumes.
- commands.{h,cpp}: every command implementation plus dispatch_command(),
  an exhaustive switch over Mode with no default -- so -Wswitch (this
  project's warning_level=3) now catches a future Mode value added without
  a matching dispatch case, instead of silently falling through. Confirmed
  by temporarily adding an unhandled enumerator and observing the warning.
- self_test.{h,cpp}: -t/--test's own file, ahead of real tests landing here.

Also fixes Mode::mount, which previously had no explicit dispatch check at
all -- it ran only because it was whatever fell off the end of main()'s
if/else chain when nothing else matched. It's now mount_command(), a real
case in dispatch_command() like every other mode.

main.cpp itself shrinks to ~30 lines: load config, apply its log level,
parse_args(), dispatch_command().

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
2026-08-24 14:07:57 +00:00

29 lines
962 B
C++

// Copyright (C) 2026 Viorel Munteanu
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include "self_test.h"
#include <fmt/core.h>
#include "bwrap.h"
int run_self_tests() {
for (const auto& arg : detect_bwrap_unshare_args()) {
fmt::print("{}\n", arg);
}
return 0;
}