Add simple argument parser and help text

This commit is contained in:
Laura Hausmann 2023-01-23 21:14:00 +01:00
parent 9614e6400f
commit f25c054b48
Signed by: zotan
GPG key ID: D044E84C5BE01605

View file

@ -27,9 +27,10 @@ namespace tgcli;
// ReSharper disable once InconsistentNaming
public static class tgcli {
public const bool lockInputToBottom = true;
public static volatile Td.TdClient client = new();
public static string dbdir = "";
public const string version = "0.4a";
public static volatile bool lockInputToBottom;
public static volatile Td.TdClient client = new();
public static string dbdir = "";
public static volatile bool authorized;
public static volatile string connectionState = "Connecting";
public static long currentChatId = 0;
@ -47,8 +48,24 @@ public static class tgcli {
public static volatile object @lock = new();
private static void Main(string[] args) {
if (args.Length == 1 && args[0] == "-s")
if (args.Contains("-s"))
silent = true;
if (args.Contains("-l"))
lockInputToBottom = true;
if (args.Contains("-h") || args.Contains("-?") || args.Contains("--help")) {
Console.WriteLine($"""
tgcli v{version}
Laura Hausmann <laura@hausmann.dev>
Source Code: https://git.ztn.sh/zotan/tgcli
Arguments:
-s Silent mode. Disables terminal bell on new message.
-l Locks input line to bottom, like in an IRC client.
""");
return;
}
dbdir = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}{Path.DirectorySeparatorChar}.tgcli"
@ -361,7 +378,7 @@ public static class tgcli {
SystemLanguageCode = "en_US",
DeviceModel = Environment.MachineName,
SystemVersion = ".NET Core CLR " + Environment.Version,
ApplicationVersion = "0.3a",
ApplicationVersion = version,
EnableStorageOptimizer = true,
UseSecretChats = true
});