Пример #1
0
        static void Main(string[] allArgs)
        {
            var ap  = new ArgParser();
            var res = ap.Parse(allArgs);

            if (res.Success)
            {
                Addresses.LoadUserAddresses();

                ap.RunDict(new ArgHandler(
                               new AHDict {
                    { "init", new ArgHandler(null, args => {
                            if (!GDMake.IsGlobalInitialized())
                            {
                                GDMake.ShowGlobalNotInitializedError();
                                return;
                            }

                            var project = new Project();

                            project.Name = ap.GetFlagOrArg("name", args, 0);
                            project.Dir  = ap.GetFlagOrArg("dir", args, 1);

                            var res = project.Save(ap.HasFlag("mkdir"), !ap.HasFlag("no-example"));

                            if (res.Failure)
                            {
                                Console.WriteLine($"Error initializing: {(res as ErrorResult<string>).Message}");
                            }
                            else
                            {
                                Console.WriteLine(res.Data);
                            }
                        }) },
Пример #2
0
        static void DefaultHandlerProjectRun(ArgParser ap, List <string> args)
        {
            var project = new Project();

            project.Dir = ap.GetFlagOrArg("dir", args, 0);

            var res = project.Load();

            if (res.Failure)
            {
                Console.WriteLine($"Error: {(res as ErrorResult).Message}");
            }
            else
            {
                res = project.Generate(false, ap.HasFlag("re"), ap.HasFlag("vgen"));

                if (res.Failure)
                {
                    Console.WriteLine($"Error: {(res as ErrorResult).Message}");
                }
                else
                {
                    res = project.Build(
                        ap.GetFlagValue("outlvl") ?? "silent",
                        ap.GetFlagValue("config") ?? "RelWithDebInfo"
                        );

                    if (res.Failure)
                    {
                        Console.WriteLine($"Error: {(res as ErrorResult).Message}");
                    }
                    else
                    {
                        res = project.Run();

                        if (res.Failure)
                        {
                            Console.WriteLine($"Error: {(res as ErrorResult).Message}");
                        }
                    }
                }
            }
        }