Files
InstanceBrick--nightcap/include/runtime/command_line.h
T
2026-08-12 01:58:18 +03:00

76 lines
2.6 KiB
C++

// Copyright 2026 Mocktail Project Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MOCKTAIL_RUNTIME_COMMAND_LINE_H_
#define MOCKTAIL_RUNTIME_COMMAND_LINE_H_
#include <string>
#include <vector>
namespace mocktail {
namespace runtime {
enum class CommandMode {
kRun,
kHelp,
};
enum class WindowMode {
kUnspecified,
kHeadless,
kWindowed,
};
struct CommandLineOptions {
CommandMode mode = CommandMode::kRun;
WindowMode window_mode = WindowMode::kUnspecified;
std::string program_name = "mocktail";
std::string roblox_library_path;
std::string graphics_backend;
// Raw browser/internal input exists only until the composition root creates
// safe re-exec arguments, then it is overwritten in this string and argv.
std::string raw_launch_argument;
std::string launch_request_json;
int launch_argument_index = -1;
bool allow_unverified_build = false;
};
struct CommandLineParseResult {
CommandLineOptions options;
std::string error;
explicit operator bool() const { return error.empty(); }
};
CommandLineParseResult ParseCommandLine(int argc, const char* const argv[]);
// Produces argv[1..] for a possible cgroup re-exec. A raw website URI is
// replaced with the already-normalized internal request, so browser gameinfo
// tickets do not cross the exec boundary.
bool BuildCommandLineReexecArguments(const CommandLineOptions& options,
int argc, const char* const argv[],
std::vector<std::string>* arguments,
std::string* error);
// Overwrites the original raw launch argument and both owned launch strings
// after the request and sanitized re-exec argv have been created.
void ScrubCommandLineLaunchArguments(CommandLineOptions* options, int argc,
char* argv[]);
bool ApplyCommandLineEnvironment(const CommandLineOptions& options,
std::string* error);
std::string CommandLineUsage(const std::string& program_name);
} // namespace runtime
} // namespace mocktail
#endif // MOCKTAIL_RUNTIME_COMMAND_LINE_H_