Esempio n. 1
0
        protected override void DoRun(string[] args)
        {
            if (ExpandInputDirectories)
            {
                List <string> newInput = new List <string>();
                foreach (string s in Input)
                {
                    if (Path.GetExtension(s) == "")
                    {
                        newInput.AddRange(Directory.GetFiles(s, "*.flc", SearchOption.AllDirectories));
                        newInput.AddRange(Directory.GetFiles(s, "*.fl", SearchOption.AllDirectories));
                    }
                    else
                    {
                        newInput.Add(s);
                    }
                }

                Input = newInput.ToArray();
            }

            for (int i = 0; i < Input.Length; i++)
            {
                string input = Path.GetFullPath(Input[i]);
                if (!SupportedInputExtensions.Select(x => string.IsNullOrEmpty(x) ? "" : "." + x)
                    .Contains(Path.GetExtension(input)))
                {
                    throw new Exception("Extension is not supported: " + Path.GetExtension(input));
                }

                string output = Output.Length <= i
                                    ? Path.Combine(
                    Path.GetDirectoryName(input),
                    Path.GetFileNameWithoutExtension(input) +
                    "." +
                    SupportedOutputExtensions.First()
                    )
                                    : Output[i];

                FLData.SetProgress(
                    $"{Path.GetFileName(input)} => {Path.GetFileName(output)}",
                    0,
                    i + 1,
                    Input.Length
                    );
                if (!SupportedOutputExtensions.Select(x => string.IsNullOrEmpty(x) ? "" : "." + x)
                    .Contains(Path.GetExtension(output)))
                {
                    throw new Exception("Extension is not supported: " + Path.GetExtension(output));
                }

                Run(input, output);
            }
        }
        protected override void Run(string input, string output)
        {
            int    maxProgress     = 2;
            int    currentProgress = 1;
            string oldDir          = Directory.GetCurrentDirectory();

            Directory.SetCurrentDirectory(input);
            if (ExportFL)
            {
                string dir = Path.Combine(
                    oldDir,
                    "temp_" +
                    Path.GetFileNameWithoutExtension(Directory.GetCurrentDirectory())
                    );
                CopyDirectory(Directory.GetCurrentDirectory(), dir);
                Directory.SetCurrentDirectory(dir);
                string[] files = Directory.GetFiles(dir, "*.fl", SearchOption.AllDirectories);

                maxProgress += files.Length;
                FLData.SetProgress("Exporting FL Scripts..", 1, currentProgress, maxProgress);
                currentProgress++;
                for (int i = 0; i < files.Length; i++)
                {
                    string file = files[i];

                    FLData.SetProgress("Exporting File:" + file, 2, currentProgress, maxProgress);
                    currentProgress++;

                    SerializableFLProgram prog = Parse(file, Defines);

                    string f = file + "c";
                    Save(f, prog, ExtraSteps);

                    if (!KeepFL)
                    {
                        File.Delete(file);
                    }
                }
            }

            FLData.SetProgress("Creating Package.", 1, currentProgress, maxProgress);
            currentProgress++;

            Directory.SetCurrentDirectory(oldDir);
            ResourceManager.Create(
                input,
                output,
                PackageName,
                UnpackConfig,
                null
                );

            FLData.SetProgress("Cleaning Up.", 1, currentProgress, maxProgress);
        }
        public void Run(string[] args)
        {
            CommandRunnerDebugConfig.Settings.MinSeverity = Utility.ADL.Verbosity.Level3;
            Runner r = new Runner();

            r._AddCommand(
                new SetDataCommand(
                    strings => Verbosity = int.Parse(strings.First()),
                    new[] { "--verbosity", "-v" },
                    "The Verbosity Level (lower = less logs)"
                    )
                );
            r._AddCommand(new DefaultHelpCommand(true));
            r._AddCommand(
                new SetDataCommand(
                    strings => Unpack = strings,
                    new[] { "--unpack", "-unpack" },
                    "Unpacks a plugins assembly data by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => List = strings,
                    new[] { "--list", "-list" },
                    "Lists All loaded files or All files inside an assembly if arguments are passed"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => FileUnpack = strings,
                    new[] { "--unpack-file", "-unpack-file" },
                    "Unpacks a plugins assembly data by file"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => FileList = strings,
                    new[] { "--list-file", "-list-file" },
                    "Lists All loaded files or All files inside an assembly if arguments are passed"
                    )
                );

            FLData.InitializePluginSystemOnly(true);

            r._RunCommands(args);

            IEnumerable <BasePluginPointer> global =
                ListHelper.LoadList(PluginPaths.GlobalPluginListFile).Select(x => new BasePluginPointer(x));

            Run(y => global.FirstOrDefault(x => x.PluginName == y)?.PluginFile, Unpack, List);

            Run(Path.GetFullPath, FileUnpack, FileList);
        }
Esempio n. 4
0
        private void CheckOriginsExists(PluginAssemblyPointer ptr)
        {
            string file = RepositoryPlugin.GetOriginFilePath(ptr);

            Directory.CreateDirectory(Path.GetDirectoryName(file));
            if (!File.Exists(file))
            {
                bool res = FLData.ShowDialog(
                    "[repo]",
                    $"{ptr.PluginName}: First Startup.",
                    "Do you want to create the default Origins File?"
                    );
                if (res)
                {
                    WriteDefaultOrigin(file);
                }
            }
        }
Esempio n. 5
0
        public void Run(string[] args)
        {
            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;
            Runner r = new Runner();

            r._AddCommand(
                new SetDataCommand(
                    strings => Adds = strings,
                    new[] { "--add", "-a" },
                    "Adds a Plugin package"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => Removes = strings,
                    new[] { "--remove", "-r" },
                    "Removes a Plugin package"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => Verbosity = int.Parse(strings.First()),
                    new[] { "--verbosity", "-v" },
                    "The Verbosity Level (lower = less logs)"
                    )
                );
            r._AddCommand(new DefaultHelpCommand(true));

            r._RunCommands(args);

            FLData.InitializePluginSystemOnly(true);

            foreach (string remove in Removes)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.REMOVE_PACKAGE_ACTION} {remove}");
            }

            foreach (string adds in Adds)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.ADD_ACTIVATE_PACKAGE_ACTION} {adds}");
            }

            Debug.OnConfigCreate -= ProjectDebugConfig_OnConfigCreate;
        }
Esempio n. 6
0
        public void Run(string[] args)
        {
            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;

            Runner r = new Runner();

            r._AddCommand(new DefaultHelpCommand());
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageAdds = strings,
                    new[] { "--add", "-a" },
                    "Adds a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageAdds = strings,
                    new[] { "--add-activate", "-aa" },
                    "Adds and activates a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageRemoves = strings,
                    new[] { "--remove", "-r" },
                    "Removes a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageActivates = strings,
                    new[] { "--activate", "-active" },
                    "Activates a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageDeactivates = strings,
                    new[] { "--deactivate", "-d" },
                    "Deactivates a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => OriginRemoves = strings,
                    new[] { "--remove-origin", "-ro" },
                    "Removes an Origin Url from the Origins File"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => OriginAdds = strings,
                    new[] { "--add-origin", "-ao" },
                    "Adds an Origin Url to the Origins File"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => DefaultOrigin = true,
                    new[] { "--default-origin", "-default" },
                    "Writes the Default Origin File to Disk, overwriting the current origin file"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => InstallAll = true,
                    new[] { "--all", "-all" },
                    "Installs and activates All packages from all repositories"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => ListPackages = true,
                    new[] { "--list-packages", "-list" },
                    "Lists All packages from all repositories"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => Verbosity = int.Parse(strings.First()),
                    new[] { "--verbosity", "-v" },
                    "The Verbosity Level (lower = less logs)"
                    )
                );


            FLData.InitializePluginSystemOnly(true);


            r._RunCommands(args);

            if (DefaultOrigin)
            {
                string file = RepositoryPlugin.GetOriginFilePath(GetDefaultRepoPluginPointer());
                Directory.CreateDirectory(Path.GetDirectoryName(file));
                WriteDefaultOrigin(file);
            }
            else
            {
                CheckOriginsExists(GetDefaultRepoPluginPointer());
            }

            RepositoryPlugin repo = GetPlugin();

            List <Repository> repos = repo.GetPlugins();
            IEnumerable <BasePluginPointer> global =
                ListHelper.LoadList(PluginPaths.GlobalPluginListFile).Select(x => new BasePluginPointer(x));
            IEnumerable <BasePluginPointer> active =
                ListHelper.LoadList(PluginPaths.PluginListFile).Select(x => new BasePluginPointer(x));

            if (ListPackages)
            {
                Console.WriteLine("Available Packages: ");
                foreach (Repository repository in repos)
                {
                    Console.WriteLine($"\tRepository: {repository.RepositoryOrigin}");
                    foreach (BasePluginPointer basePluginPointer in repository.Plugins)
                    {
                        BasePluginPointer installedPtr =
                            global.FirstOrDefault(x => x.PluginOrigin == basePluginPointer.PluginOrigin);
                        bool   contained = installedPtr != null;
                        bool   installed = contained && active.Any(x => x.PluginOrigin == basePluginPointer.PluginOrigin);
                        string tag       = installed ? "[ACTIVE]" : contained ? "[INSTALLED]" : "[NOT INSTALLED]";
                        Console.WriteLine($"\t\t{tag} {basePluginPointer.PluginName}");
                        Console.WriteLine($"\t\t\tVersion(Origin): {basePluginPointer.PluginVersion}");
                        Console.WriteLine(
                            $"\t\t\tVersion(Installed): {installedPtr?.PluginVersion?.ToString() ?? "NOT INSTALLED"}"
                            );
                    }
                }
            }

            if (InstallAll)
            {
                PackageAddsActivates = repos.SelectMany(x => x.Plugins.Select(y => y.PluginName)).ToArray();
            }

            foreach (string originRemove in OriginRemoves)
            {
                repo.RemoveOrigin(originRemove);
            }

            foreach (string originAdd in OriginAdds)
            {
                repo.AddOrigin(originAdd);
            }

            foreach (string packageDeactivate in PackageDeactivates)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.DEACTIVATE_PACKAGE_ACTION} {packageDeactivate}");
            }

            foreach (string packageRemove in PackageRemoves)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.REMOVE_PACKAGE_ACTION} {packageRemove}");
            }

            foreach (string packageAdd in PackageAdds)
            {
                string package = GetPackage(repos, packageAdd);
                if (package == null)
                {
                    PluginManager.SendLog("Can not Add Package. Url does not exist.");
                    continue;
                }

                ActionRunner.AddActionToStartup($"{ActionRunner.ADD_PACKAGE_ACTION} {package}");
            }

            foreach (string packageAddActivate in PackageAddsActivates)
            {
                string package = GetPackage(repos, packageAddActivate);

                if (package == null)
                {
                    PluginManager.SendLog("Can not Add Package. Url does not exist.");
                    continue;
                }

                ActionRunner.AddActionToStartup($"{ActionRunner.ADD_ACTIVATE_PACKAGE_ACTION} {package}");
            }

            foreach (string packageActivate in PackageActivates)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.ACTIVATE_PACKAGE_ACTION} {packageActivate}");
            }


            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;
        }
Esempio n. 7
0
        public void Run(string[] args)
        {
            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;

            AbstractCommand.MIN_COMMAND_SEVERITY = 0;

            Runner r = new Runner();

            r._AddCommand(
                new SetDataCommand(
                    s => NoDialog = true,
                    new[] { "--yes" },
                    "Answer all dialogs with Yes"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => Verbosity = int.Parse(strings.First()),
                    new[] { "--verbosity", "-v" },
                    "The Verbosity Level (lower = less logs)"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => CheckTypes =
                        (FLProgramCheckType)Enum.Parse(
                            typeof(FLProgramCheckType),
                            strings.First(),
                            true
                            ),
                    new[] { "--checks", "-checks" },
                    $"Program Check Profile. (Available: {Enum.GetNames(typeof(FLProgramCheckType)).Unpack(", ")})"
                    )
                );
            r._AddCommand(new DefaultHelpCommand(true));
            AddCommands(r);

            Debug.DefaultInitialization();
            r._RunCommands(args);
            if (AbortRun)
            {
                Console.ReadLine();
                return;
            }

            foreach (KeyValuePair <IProjectDebugConfig, List <ADLLogger> > keyValuePair in ADLLogger.GetReadOnlyLoggerMap()
                     )
            {
                keyValuePair.Key.SetMinSeverity(Verbosity);
            }

            OpenFLDebugConfig.Settings.SetMinSeverity(Verbosity);

            FLData.InitializeFL(NoDialog, CheckTypes);

            BeforeRun();

            DoRun(args);

            AfterRun();

            Debug.OnConfigCreate -= ProjectDebugConfig_OnConfigCreate;
        }