Remove -mm short form, require --mmproj only

This commit is contained in:
wangjue 2026-05-29 16:20:56 +08:00
parent d8edd92302
commit 55ab885722

View File

@ -8,7 +8,6 @@
#include <csignal> #include <csignal>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring>
#include <getopt.h> #include <getopt.h>
#include <string> #include <string>
#include <sys/stat.h> #include <sys/stat.h>
@ -18,8 +17,11 @@
static volatile bool g_interrupted = false; static volatile bool g_interrupted = false;
static void noop_log(enum ggml_log_level level, const char * text, void * user_data) { static void noop_log(const ggml_log_level level, const char *text,
(void)level; (void)text; (void)user_data; void *user_data) {
(void)level;
(void)text;
(void)user_data;
} }
static void sigint_handler(const int signo) { static void sigint_handler(const int signo) {
@ -102,7 +104,7 @@ static std::vector<unsigned char> read_clipboard() {
while ((n = fread(buf, 1, sizeof(buf), pipe)) > 0) { while ((n = fread(buf, 1, sizeof(buf), pipe)) > 0) {
data.insert(data.end(), buf, buf + n); data.insert(data.end(), buf, buf + n);
} }
int st = pclose(pipe); const int st = pclose(pipe);
if (st != 0 || data.empty()) { if (st != 0 || data.empty()) {
data.clear(); data.clear();
// fallback for X11: try without explicit target // fallback for X11: try without explicit target
@ -124,7 +126,8 @@ static std::string capture_screenshot(bool quiet) {
tmpdir = "/tmp"; tmpdir = "/tmp";
std::string path = std::string(tmpdir) + "/ocr_screenshot.png"; std::string path = std::string(tmpdir) + "/ocr_screenshot.png";
if (!quiet) fprintf(stderr, "Select a screen region to OCR...\n"); if (!quiet)
fprintf(stderr, "Select a screen region to OCR...\n");
auto check = [&]() -> bool { auto check = [&]() -> bool {
struct stat st {}; struct stat st {};
@ -173,7 +176,7 @@ static void print_usage(const char *prog) {
"\n" "\n"
"Options:\n" "Options:\n"
" -m, --model <path> model file path (GGUF)\n" " -m, --model <path> model file path (GGUF)\n"
" --mmproj,--mm <path> mmproj file path\n" " --mmproj <path> mmproj file path\n"
" -p <text> OCR prompt (default: OCR)\n" " -p <text> OCR prompt (default: OCR)\n"
" -t <n> number of threads (default: cpu cores)\n" " -t <n> number of threads (default: cpu cores)\n"
" --ngl <n> GPU layers (-1 = all, default: -1)\n" " --ngl <n> GPU layers (-1 = all, default: -1)\n"
@ -212,19 +215,11 @@ int main(int argc, char **argv) {
bool json_output = false; bool json_output = false;
bool quiet = false; bool quiet = false;
// pre-process -mm to --mmproj so getopt handles it correctly
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-mm") == 0) {
argv[i] = (char *)"--mmproj";
}
}
while (true) { while (true) {
static option long_opts[] = { static option long_opts[] = {
{"temp", required_argument, nullptr, 0}, {"temp", required_argument, nullptr, 0},
{"json", no_argument, nullptr, 1}, {"json", no_argument, nullptr, 1},
{"mmproj", required_argument, nullptr, 2}, {"mmproj", required_argument, nullptr, 2},
{"mm", required_argument, nullptr, 2},
{"ngl", required_argument, nullptr, 3}, {"ngl", required_argument, nullptr, 3},
{"model", required_argument, nullptr, 'm'}, {"model", required_argument, nullptr, 'm'},
{"chat-template", required_argument, nullptr, 4}, {"chat-template", required_argument, nullptr, 4},
@ -284,7 +279,7 @@ int main(int argc, char **argv) {
} }
if (model_path.empty() || mmproj_path.empty()) { if (model_path.empty() || mmproj_path.empty()) {
fprintf(stderr, "ERROR: -m/--model and --mmproj/--mm are required\n"); fprintf(stderr, "ERROR: -m/--model and --mmproj are required\n");
return 1; return 1;
} }
@ -367,7 +362,8 @@ int main(int argc, char **argv) {
return 1; return 1;
} }
} else { } else {
if (!quiet) fprintf(stderr, "Reading image from clipboard...\n"); if (!quiet)
fprintf(stderr, "Reading image from clipboard...\n");
auto clip = read_clipboard(); auto clip = read_clipboard();
if (clip.empty()) { if (clip.empty()) {
fprintf(stderr, fprintf(stderr,