Beispiel #1
0
        public void Handle(string[] args)
        {
            GitHubOpenAppDataDirectory.EnsureExists();

            var newAlias = $"{_parsedArgs.Alias},{_parsedArgs.GitRepositoryRootDirectory},{_parsedArgs.ParametersString}";

            File.AppendAllLines(GitHubOpenAppDataDirectory.AliasesFilePath, new [] { newAlias }, Encoding.UTF8);
        }
Beispiel #2
0
        private static (bool foundAlias, Alias alias) TryResolveKnownAlias(string[] args)
        {
            GitHubOpenAppDataDirectory.EnsureExists();

            if (File.Exists(GitHubOpenAppDataDirectory.AliasesFilePath))
            {
                var aliasesLines = File.ReadAllLines(GitHubOpenAppDataDirectory.AliasesFilePath);

                var aliases = Alias.ParseFromFile(aliasesLines);

                var alias = aliases.FirstOrDefault(a => args.Contains(a.Key));

                return(alias != null, alias);
            }

            return(false, null);
        }
Beispiel #3
0
        public void Handle(string[] args)
        {
            GitHubOpenAppDataDirectory.EnsureExists();

            var lines   = File.ReadAllLines(GitHubOpenAppDataDirectory.AliasesFilePath, Encoding.UTF8);
            var aliases = Alias.ParseFromFile(lines);

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"Aliases ({GitHubOpenAppDataDirectory.AliasesFilePath}):");

            foreach (var alias in aliases)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("  Key: ");

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write($"{alias.Key}{Environment.NewLine}");

                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("  Path: ");

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write($"{alias.DirectoryPath}{Environment.NewLine}");

                if (alias.Parameters.Any())
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("  Parameters: ");

                    foreach (var parameter in alias.Parameters)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write($"{parameter}{Environment.NewLine}");
                    }
                }

                Console.WriteLine(Environment.NewLine);
            }

            Console.ResetColor();
        }