Skip to content

Commit

Permalink
Show version
Browse files Browse the repository at this point in the history
  • Loading branch information
praeclarum committed Mar 21, 2023
1 parent dcb1b36 commit 7bd0322
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions AskGPT/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,33 @@
}
else if (option == "help")
{
ShowHelp(cmdName);
ShowHelp();
return 0;
}
else if (option == "version")
{
ShowVersion();
return 0;
}
else {
Error($"Unknown option: {option}");
}
}
if (arg.StartsWith("-") && promptParts.Count == 0) {
foreach (var c in arg.Substring(1)) {
switch (c) {
case 'h':
ShowHelp();
return 0;
case 'v':
ShowVersion();
return 0;
default:
Error($"Unknown option: {c}");
break;
}
}
}
else {
promptParts.Add(arg);
}
Expand Down Expand Up @@ -190,15 +210,23 @@ static void Error(string message)
Environment.Exit(1);
}

static void ShowHelp(string cmdName)
void ShowHelp()
{
Console.WriteLine($"Usage: {cmdName} [options] prompt");
Console.WriteLine();
Console.WriteLine("Options:");
Console.WriteLine(" --model <model-id> The model to use. Defaults to gpt-3.5-turbo.");
Console.WriteLine(" --help Show this help message.");
Console.WriteLine(" -h, --help Show this help message.");
Console.WriteLine(" -v, --version Show the version of this program.");
Console.WriteLine();
Console.WriteLine($"Provide a prompt as the arguments to this program.\n\nFor example:\n\n{cmdName} What is the meaning of life?");
Console.WriteLine($"Provide a prompt as the arguments to this program.\n\nFor example:\n\n{cmdName} \"What is the meaning of life?\"");
}

void ShowVersion()
{
var asm = System.Reflection.Assembly.GetExecutingAssembly();
var version = asm.GetName().Version;
Console.WriteLine($"{appName} version: {version}");
}

class HistoricMessage
Expand Down

0 comments on commit 7bd0322

Please sign in to comment.