Skip to content

Commit 050ee92

Browse files
authored
app : allow --version, --licenses & --help (ggml-org#25054)
Signed-off-by: Adrien Gallouët <angt@huggingface.co>
1 parent 3fc4e10 commit 050ee92

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

app/llama.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct command {
5050
std::vector<std::string> aliases;
5151
bool hidden;
5252
int (*func)(int, char **);
53+
bool flags = false; // allow --name
5354
};
5455

5556
#ifdef LLAMA_INSTALL_BUILD
@@ -69,9 +70,9 @@ static const command cmds[] = {
6970
{"fit-params", "Compute parameters to fit a model in device memory", {}, true, llama_fit_params },
7071
{"quantize", "Quantize a model", {}, true, llama_quantize },
7172
{"perplexity", "Compute model perplexity and KL divergence", {}, true, llama_perplexity },
72-
{"version", "Show version", {}, false, version },
73-
{"licenses", "Show third-party licenses", {"credits"}, false, licenses },
74-
{"help", "Show available commands", {}, false, help },
73+
{"version", "Show version", {}, false, version, true },
74+
{"licenses", "Show third-party licenses", {"credits"}, false, licenses, true },
75+
{"help", "Show available commands", {}, false, help, true },
7576
};
7677

7778
#undef UPDATE_HIDDEN
@@ -108,7 +109,10 @@ static int help(int argc, char ** argv) {
108109
return 0;
109110
}
110111

111-
static bool matches(const std::string & arg, const command & cmd) {
112+
static bool matches(std::string arg, const command & cmd) {
113+
if (cmd.flags && arg.size() > 2 && arg[0] == '-' && arg[1] == '-') {
114+
arg.erase(0, 2);
115+
}
112116
if (arg == cmd.name) {
113117
return true;
114118
}

0 commit comments

Comments
 (0)