Пример #1
0
            // mods…
            // text…

            public static AlfredItem FromLocation(ExpressVPNClient client, ExpressVPNClient.Location loc, bool withUid = true)
            {
                var prefix = "";
                var action = $"connect {loc.id}";

                var connectedId = client.LatestStatus.current_location.id;

                if (loc.id == connectedId)
                {
                    prefix = "⚡️ ";
                    action = "disconnect";
                }
                else
                {
                    if (loc.favorite)
                    {
                        prefix += "❤️";
                    }
                    if (client.RecentLocationIds.Contains(loc.id))
                    {
                        prefix += "🕙";
                    }
                    if (client.DefaultLocationId == loc.id)
                    {
                        prefix += "👍";
                    }
                    if (prefix.Length > 0)
                    {
                        prefix = prefix + " ";
                    }
                }

                string uid = null;

                if (withUid)
                {
                    uid = loc.id;
                }

                return(new AlfredItem()
                {
                    uid = uid,
                    title = loc.name,
                    subtitle = $"{prefix}{loc.region} - {loc.country}",
                    arg = action,
                    icon = new AlfredIcon()
                    {
                        path = $"./flags/{loc.country_code}.png",
                    },
                    valid = true,
                    match = $"{loc.name} {loc.region} {loc.country_code}",
                });
            }
Пример #2
0
        async Task Setup()
        {
            enableColors = Environment.GetEnvironmentVariable("CLICOLORS") != "0";

            var level = LogLevel.Warning;

            if (quiet)
            {
                level = LogLevel.Error;
            }
            else if (verbose >= 3)
            {
                level = LogLevel.Trace;
            }
            else if (verbose == 2)
            {
                level = LogLevel.Debug;
            }
            else if (verbose == 1)
            {
                level = LogLevel.Information;
            }

            LoggerFactory = new LoggerFactory()
                            .AddNiceConsole(level, false);
            Logger = LoggerFactory.CreateLogger <ExpressoCLI>();

            Logger.LogInformation($"{PROGRAM_NAME} v{GetVersion()}");
            if (level != LogLevel.Warning)
            {
                Logger.LogInformation($"Log level set to {level}");
            }

            client = new ExpressVPNClient(LoggerFactory.CreateLogger <ExpressVPNClient>());
            await client.WaitForConnection();

            Logger.LogInformation($"Connected to ExpressVPN version {client.AppVersion}");

            await client.UpdateStatus();
        }