public static void Main(string[] args)
        {
            ConsoleExtended.WriteLineWithDelay("SuperCool Compiler Platform");
            ConsoleExtended.WriteLineWithDelay("Copyright (C) Jose Ariel Romero & Jorge Yero Salazar & Jose Diego Menendez del Cueto. All rights reserved.");
            Console.WriteLine();

            //args = new[] { "..\\..\\..\\..\\..\\tests\\SuperCOOL.Tests\\Examples\\Cool\\hello_world.cl" };
            if (args.Length == 0)
            {
                Console.WriteLine("I need something to compile...");
                return;
            }

            var Errors = Compile(args, out var Code, out var limits);

            //PrintErrors
            foreach (var item in Errors)
            {
                Console.WriteLine(item.ToString(limits));
            }

            if (Errors.Count() == 0)
            {
                Console.WriteLine(Code);
            }
        }
Example #2
0
        private void WritePullRequest(ConsoleExtended console, PullRequest pr)
        {
            console.WriteLine(ConsoleColor.Yellow, "Request: {0} <{1}>", pr.Id, pr.Links.Self[0].Href.ToString());
            console.WriteLine("Created: " + DateTimeUtils.FromEpochMilliseconds(pr.CreatedDate));
            console.WriteLine("Author: {0} <{1}>",
                              (pr.Author?.User?.DisplayName ?? "None"),
                              (pr.Author?.User?.EmailAddress ?? "None"));

            console.WriteLine("Status: " + pr.State);
            console.WriteLine("Branches: {0} -> {1}",
                              (pr.FromRef?.DisplayId ?? "None"),
                              (pr.ToRef?.DisplayId ?? "None"));

            foreach (var reviewer in pr.Reviewers)
            {
                console.Write("Reviewer: {0} <{1}> - ",
                              (reviewer.User?.DisplayName ?? "None"),
                              (reviewer.User?.EmailAddress ?? "None"));

                var statusColor = ConsoleColor.Gray;
                switch (reviewer.Status)
                {
                case "APPROVED":
                    statusColor = ConsoleColor.Green;
                    break;

                case "UNAPPROVED":
                    statusColor = ConsoleColor.Yellow;
                    break;
                }
                console.WriteLine(statusColor, reviewer.Status);
            }
            console.WriteLine();
            console.WriteLine(pr.Description ?? "<No Description>");
        }
Example #3
0
        /// <summary>
        /// Writes a warning line
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="callerMember"></param>
        /// <param name="message"></param>
        public static void WriteWarningLine(this object caller, [CallerMemberName] string callerMember = "", string message = "")
        {
            var line = GetLine(caller, callerMember, message);

            ConsoleExtended.WritePrefixedLine(WarningPrefix, line,
                                              backgroundColor: ConsoleColor.Black,
                                              prefixColor: ConsoleColor.DarkYellow,
                                              textColor: ConsoleColor.Gray);
        }
        static void Main(string[] args)
        {
            ConsoleExtended.WriteLine("Welcome on the demo for Kuchulem's console helpers", ConsoleTextAlignment.Left);
            ConsoleExtended.WritePrefixedLine("Info", "This is a prefixed line (with [info] keyword here). You will " +
                                              "see them when important information is displayed", prefixColor: ConsoleColor.Yellow);

            ConsoleExtended.NewLine();
            ConsoleExtended.WriteLine("Let's starts by drawing a patter (The Kuchulem logo)", ConsoleTextAlignment.Left);
            ConsoleExtended.DrawPattern(
                // first argument is the pattern
                "                       " + Environment.NewLine +
                "  **** **        ****  " + Environment.NewLine +
                "  **   **          **  " + Environment.NewLine +
                "  **   **     **   **  " + Environment.NewLine +
                "  **   **   **     **  " + Environment.NewLine +
                "  **   ** **       **  " + Environment.NewLine +
                "  **   **   **     **  " + Environment.NewLine +
                "  **   **     **   **  " + Environment.NewLine +
                "  **   **          **  " + Environment.NewLine +
                "  **** **        ****  " + Environment.NewLine +
                "                       ",
                // second argument is a dictrionnary that makes
                // a correspondance between a character and a color
                new Dictionary <char, ConsoleColor?>
            {
                { ' ', ConsoleColor.DarkBlue },
                { '*', ConsoleColor.Yellow }
            },
                // Third parameter to align the pattern (here centered)
                ConsoleTextAlignment.Center
                );

            ConsoleExtended.WritePrefixedLine("Info", "Once the pattern is drawn, the console colors return back to normal", prefixColor: ConsoleColor.Yellow);

            ConsoleExtended.NewLine();
            ConsoleExtended.WriteLine("Now let's play with alignment !", ConsoleTextAlignment.Left);
            ConsoleExtended.WriteLine("Actually you saw text aligned to left", ConsoleTextAlignment.Left);
            ConsoleExtended.WriteLine("But you can center your text", ConsoleTextAlignment.Center);
            ConsoleExtended.WriteLine("And align it to right", ConsoleTextAlignment.Right);
            ConsoleExtended.WritePrefixedLine("Info", "Note that the alignment is only for a single Console.WriteLine call.", prefixColor: ConsoleColor.Yellow);
            ConsoleExtended.WriteLine(
                "The alignment" + Environment.NewLine +
                "Can be kept on a multiline" + Environment.NewLine +
                "text",
                ConsoleTextAlignment.Center);

            ConsoleExtended.NewLine();
            ConsoleExtended.WriteLine("Time to play with colors !", ConsoleTextAlignment.Left);
            ConsoleExtended.WriteLine("You can change foreground and background color for a single call of Console.WriteLine.", ConsoleTextAlignment.Left, ConsoleColor.Cyan, ConsoleColor.Magenta);
            ConsoleExtended.WriteLine("The following line will be back to the original color", ConsoleTextAlignment.Left);

            ConsoleExtended.NewLine();
            ConsoleExtended.WriteLine("That's all :) enjoy your console.", ConsoleTextAlignment.Left);
        }
Example #5
0
        static void Main(string[] args)
        {
            ConsoleExtended.DrawPattern(
                "                       " + Environment.NewLine +
                "  **** **        ****  " + Environment.NewLine +
                "  **   **          **  " + Environment.NewLine +
                "  **   **     **   **  " + Environment.NewLine +
                "  **   **   **     **  " + Environment.NewLine +
                "  **   ** **       **  " + Environment.NewLine +
                "  **   **   **     **  " + Environment.NewLine +
                "  **   **     **   **  " + Environment.NewLine +
                "  **   **          **  " + Environment.NewLine +
                "  **** **        ****  ",
                new Dictionary <char, ConsoleColor?>
            {
                { ' ', ConsoleColor.DarkGray },
                { '*', ConsoleColor.Black }
            },
                ConsoleTextAlignment.Center
                );
            ConsoleExtended.WriteLine("       Kuchulem       ", ConsoleTextAlignment.Center, ConsoleColor.DarkGray, ConsoleColor.Black);
            Console.WriteLine("");
            ConsoleExtended.WriteLine("", ConsoleTextAlignment.Center, ConsoleColor.DarkGray, ConsoleColor.Black, true);
            ConsoleExtended.WriteLine("Welcome on Kuchulem.MarkdownBlog Command", ConsoleTextAlignment.Center, ConsoleColor.DarkGray, ConsoleColor.Black, true);
            ConsoleExtended.WriteLine("", ConsoleTextAlignment.Center, ConsoleColor.DarkGray, ConsoleColor.Black, true);
            Console.WriteLine("");
            Parser.Default.ParseArguments <Options>(args).WithParsed(o =>
            {
                if (string.IsNullOrEmpty(o.BlogUrl))
                {
                    WriteError("No blog url provided, use option --blog [url].");
                    return;
                }

                if (o.Cache)
                {
                    RunCacheManager(o);
                }
                else
                {
                    WriteError("Use --help option to see available options.");
                }
            });
        }
        private void WriteBranches(IEnumerable <Branch> branches)
        {
            ConsoleExtended console = new ConsoleExtended();

            bool firstPr = true;

            foreach (var br in branches)
            {
                if (firstPr)
                {
                    firstPr = false;
                }
                else
                {
                    console.WriteLine();
                }
                WriteBranch(console, br);
            }
        }
Example #7
0
        private Hash DecodeCrossHash(string crossHash)
        {
            var hashes = new List <string>();

            if (crossHash.IsBase64())
            {
                crossHash = crossHash.Base64Decode();
            }

            var hash      = GetHashesFromDecodedToken(crossHash);
            var hashToken = hash.HashToken;

            hash.HashesLengthList.Reverse();
            hash.DifficultiesList.Reverse();

            var ch = hashToken.ToCharArray().ToList();

            for (var i = 0; i < hash.HashesLengthList.Count; i++)
            {
                var hashLength = i == 0 ? hash.HashesLengthList.First() : hash.HashesLengthList[i];
                try{
                    var difficulty = i == 0 ? hash.DifficultiesList.First() : hash.DifficultiesList[i];
                    try{
                        var temp = hashToken.Substring(difficulty, hashLength);
                        hashToken = hashToken.Remove(difficulty, hashLength);
                        var t = temp.ReverseString();
                        hashes.Add(t);
                    }
                    catch (Exception e) {
                        ConsoleExtended.WriteColorLine(
                            $"EXCEPTION: {e.Message} \nlengths: {difficulty}, {hashLength}, {hashToken.Length}");
                    }
                }
                catch (Exception) {
                    hashes.Add(hashToken);
                }
            }

            hash.Hashes = hashes;

            return(hash);
        }
Example #8
0
        private void WritePullRequests(Dictionary <string, List <PullRequest> > pullRequests)
        {
            var console = new ConsoleExtended();

            bool firstRepo = true;

            foreach (var kvp in pullRequests)
            {
                if (firstRepo)
                {
                    firstRepo = false;
                }
                else
                {
                    console.WriteLine("\n");
                }
                console.WriteLine(ConsoleColor.Green, "Repository: " + kvp.Key);

                bool firstPr = true;
                if (kvp.Value.Count > 0)
                {
                    foreach (var pr in kvp.Value)
                    {
                        if (firstPr)
                        {
                            firstPr = false;
                        }
                        else
                        {
                            console.WriteLine();
                        }
                        WritePullRequest(console, pr);
                    }
                }
                else
                {
                    console.WriteLine("<No Pull Requests>");
                }
            }
        }
Example #9
0
        private byte[] GenerateCryptoByte(string message, string key, string salt, int type = 0)
        {
            HashAlgorithm algorithm;

            switch (type)
            {
            case 256:
                algorithm = new SHA256Managed();
                break;

            case 512:
                algorithm = new SHA512Managed();
                break;

            case 0:
                algorithm = new SHA1Managed();
                break;

            default:
                algorithm = new MD5CryptoServiceProvider();
                break;
            }

            if (type == 1)
            {
                try{
                    return(GenerateGenericHashWithSalt(message, key, saltBytes: salt.ToByteArray())
                           .ToByteArray());
                }
                catch (Exception e) {
                    ConsoleExtended.WriteColorLine($"type {type} exception {e}");
                    return(null);
                }
            }

            var hash = algorithm.ComputeHash(message.ToByteArray());

            return(hash);
        }
Example #10
0
 private static void WriteInfo(string message)
 {
     ConsoleExtended.WritePrefixedLine("Info    :", message, ConsoleColor.DarkGray, ConsoleColor.DarkGreen, ConsoleColor.Black);
 }
Example #11
0
 private static void WriteError(string message)
 {
     ConsoleExtended.WritePrefixedLine("Error   :", message, ConsoleColor.DarkGray, ConsoleColor.DarkRed, ConsoleColor.Black);
 }
Example #12
0
 private void WriteBranch(ConsoleExtended console, Branch br)
 {
     console.WriteLine("Name: " + br.DisplayId);
     console.WriteLine("Latest Changeset: " + br.LatestChangeset);
 }
Example #13
0
        private void TestCrypto(int iterations = 100)
        {
            var fails        = 0;
            var success      = 0;
            var observations = 0;
            var failedLists  = new List <Dictionary <string, Hash> >();

            for (var i = 0; i < iterations; i++)
            {
                var encodedHash = GenerateEncodedAuthHash(difficulty: 10);
                var decodedHash = GenerateDecodedAuthHash(encodedHash.Token);

                var test1 = encodedHash.Hashes;
                var test2 = decodedHash.Hashes;
                foreach (var hash1 in test1)
                {
                    var hash2 = test2.Find(x => x == hash1);
                    var equal = hash1 == hash2;
                    if (equal)
                    {
                        test2.Remove(hash2);
                        success++;
                    }
                    else
                    {
                        fails++;
                        failedLists.Add(new Dictionary <string, Hash>
                        {
                            { "encoded_hash", encodedHash }, { "decoded_hash", decodedHash }
                        }
                                        );
                    }

                    observations++;
                }
            }

            ConsoleExtended.WriteColorLine("results:");
            ConsoleExtended.WriteColorLine($"successful results {success} of {observations} observations");
            ConsoleExtended.WriteColorLine($"failed results {fails} of {observations} observations");
            if (fails <= 0)
            {
                return;
            }
            ConsoleExtended.WriteColorLine("failed at observations:");
            foreach (var failedList in failedLists)
            {
                var enc = failedList["encoded_hash"];
                var dec = failedList["decoded_hash"];
                ConsoleExtended.WriteColorLine("failed observation encoded:");
                foreach (var eh in enc.Hashes)
                {
                    ConsoleExtended.WriteColorLine(eh);
                }

                ConsoleExtended.WriteColorLine("failed observation decoded:");
                foreach (var dh in dec.Hashes)
                {
                    ConsoleExtended.WriteColorLine(dh);
                }

                Console.WriteLine("---------------------------------------------------");
            }
        }