예제 #1
0
        public void tasksDefaultCommand()
        {
            var requestResult = _taskRepository.List(Helper.GetDefaultProjectId()).Result;

            if (requestResult != null)
            {
                foreach (var task in requestResult.ToList())
                {
                    Console.Write($"{task.Id} - {task.Description} | ");
                    switch (task.TaskStatus)
                    {
                    case DAL.Enums.TaskStatus.Planned:
                        Console.WriteLine($"{task.TaskStatus}", ConsoleColor.Blue);
                        break;

                    case DAL.Enums.TaskStatus.Fighting:
                        Console.WriteLine($"{task.TaskStatus}", ConsoleColor.Yellow);
                        break;

                    case DAL.Enums.TaskStatus.Conquered:
                        Console.WriteLine($"{task.TaskStatus}", ConsoleColor.Green);
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine("There are no tasks yet. Use 'add' and start working!");
            }
        }
예제 #2
0
        static bool Prompt(string message, bool ignoreCase, params string[] acceptedInput)
        {
            Console.Write(message);
            string ans = Console.ReadLine();

            if (ignoreCase)
            {
                ans = ans.ToLower();
            }
            for (int i = 0; i < acceptedInput.Length; i++)
            {
                if (acceptedInput[i].Equals(ans))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public static ArticleData Parse(string article, ArticleHeadInfo articleHeadInfo, bool debug = false)
        {
            string      content = File.ReadAllText(article);
            ArticleData ad      = new ArticleData(articleHeadInfo);

            MarkdownDocument document = new MarkdownDocument();

            document.Parse(content);

            List <MarkdownBlock> elements        = new List <MarkdownBlock>();
            List <ChapterData>   chapters        = new List <ChapterData>();
            ChapterData          chapter         = new ChapterData();
            List <MarkdownBlock> chapterElements = new List <MarkdownBlock>();

            void AddChapter()
            {
                if (chapterElements.Count > 0)
                {
                    chapter.Elements = chapterElements.ToArray();
                    chapters.Add(chapter);
                }
            }

            void NewChapter(HeaderBlock header)
            {
                // Add old
                AddChapter();
                // New chapter
                chapter = new ChapterData {
                    Title = header.ToString().Trim()
                };
                chapterElements = new List <MarkdownBlock>();
            }

            for (int i = 0; i < document.Blocks.Count; i++)
            {
                MarkdownBlock block = document.Blocks[i];
                if (debug)
                {
                    Console.Write($"{block.Type}: ", ConsoleColor.Cyan);
                }

                if (!IsCommentParagraph(block))
                {
                    elements.Add(block);
                }

                if (block is HeaderBlock header)
                {
                    if (header.HeaderLevel <= 2)
                    {
                        if (header.HeaderLevel == 1 && ad.TITLE == null)
                        {
                            ad.TITLE = header.ToString().Trim();
                        }
                        NewChapter(header);
                        continue;
                    }
                }

                if (!IsCommentParagraph(block))
                {
                    chapterElements.Add(block);
                }

                if (block is ParagraphBlock paragraph)
                {
                    if (debug)
                    {
                        Console.WriteLine();
                    }
                    for (int j = 0; j < paragraph.Inlines.Count; j++)
                    {
                        MarkdownInline inline = paragraph.Inlines[j];
                        if (debug)
                        {
                            Console.Write($"    {inline.Type}: ", ConsoleColor.DarkCyan);
                        }
                        if (debug)
                        {
                            Console.WriteLine(inline.ToString());
                        }
                        if (inline.Type != MarkdownInlineType.Comment)
                        {
                        }
                    }
                    if (debug)
                    {
                        Console.WriteLine("\n" + block.ToHtml());
                    }
                }
                else
                {
                    if (debug)
                    {
                        Console.WriteLine(block + "\n" + block.ToHtml());
                    }
                }
            }

            AddChapter();
            ad.CHAPTERS = chapters.ToArray();
            ad.ELEMENTS = elements.ToArray();

            return(ad);
        }
예제 #4
0
        static void Main(string[] args)
        {
            Console.Write("=== "); Console.Write("Cake", ConsoleColor.Red); Console.Write("Lang", ConsoleColor.White); Console.WriteLine(" Demo ===");

            Console.WriteLine("For version: " + CakeLang.CakeLang.Version.ToString() + '\n', ConsoleColor.DarkYellow);

            // --- Data Pack Code -----------------------------------------

            DataPack demoPack = new DataPack("Demo Pack", "A demonstration of CakeLang!", "demopack");

            string message = "Hello friend";

            demoPack.Functions.Add(new Function("fun2",
                                                AsAt("s", Run(
                                                         Tellraw('s', JSON.Text(message, JSON.StyleFormattings.Color(Colors.Aqua), JSON.StyleFormattings.Bold))
                                                         ))
                                                ));
            demoPack.Functions.Add(new Function("flying",
                                                If.Block("~ ~-1 ~", Namespace("air"),
                                                         Run(
                                                             Tellraw('s', JSON.Text("Bro, you're flying!", JSON.StyleFormattings.Color(Colors.Yellow), JSON.StyleFormattings.Italic))
                                                             )
                                                         ),
                                                Unless.Block("~ ~-1 ~", Namespace("air"),
                                                             Run(
                                                                 Tellraw('s', JSON.Text("Nah, not flyin' yet", JSON.StyleFormattings.Color(Colors.Yellow), JSON.StyleFormattings.Underlined))
                                                                 )
                                                             )
                                                ));

            ArgumentsFunction introduce = new ArgumentsFunction("introduce", new System.Collections.Generic.Dictionary <string, Type>()
            {
                ["name"]     = typeof(string),
                ["position"] = typeof(float[])
            },
                                                                Tellraw(Selector.Executor, JSON.ArrayBuilder(
                                                                            JSON.Text("My name is ", JSON.StyleFormattings.Bold, JSON.StyleFormattings.Color(Colors.Gold)),
                                                                            JSON.FunctionVariable("introduce", "name", JSON.StyleFormattings.Italic, JSON.StyleFormattings.Color(Colors.Yellow)),
                                                                            JSON.Text(", I'm at ", JSON.StyleFormattings.Bold, JSON.StyleFormattings.Color(Colors.Gold)),
                                                                            JSON.FunctionVariable("introduce", "position[0]", JSON.StyleFormattings.Italic, JSON.StyleFormattings.Color(Colors.Yellow)),
                                                                            JSON.Text(" "),
                                                                            JSON.FunctionVariable("introduce", "position[1]", JSON.StyleFormattings.Italic, JSON.StyleFormattings.Color(Colors.Yellow)),
                                                                            JSON.Text(" "),
                                                                            JSON.FunctionVariable("introduce", "position[2]", JSON.StyleFormattings.Italic, JSON.StyleFormattings.Color(Colors.Yellow)),
                                                                            JSON.Text(" "),
                                                                            JSON.Text("!", JSON.StyleFormattings.Bold, JSON.StyleFormattings.Color(Colors.Gold))
                                                                            ))
                                                                );

            demoPack.Functions.Add(introduce);

            demoPack.Functions.Add(new Function("introducePeople",
                                                introduce.Call("Jeff", new[] { 0.5f, 2f, -4f }),
                                                introduce.Call("Monica", new[] { 0, 0, 0 }),
                                                introduce.Call("Boobo", new[] { 6, 6, 9, -2 })
                                                ));

            // --- Data Pack Code -----------------------------------------

            try
            {
                demoPack.CompileAndInject("CakeLang Demo");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message, ConsoleColor.Red);
            }
        }