Exemplo n.º 1
0
 private void PrintHelp()
 {
     ConsoleWrapper.WriteText("Help - SymOntoClay CLI:");
     ConsoleWrapper.WriteText("");
     ConsoleWrapper.WriteText("Running CLI without arguments prints help.");
     ConsoleWrapper.WriteText("");
     ConsoleWrapper.WriteText("CLI arguments:");
     ConsoleWrapper.WriteText("h - prints help.");
     ConsoleWrapper.WriteText("help - prints help.");
     ConsoleWrapper.WriteText("run <NPC file name> - runs NPC and waits when you write 'exit' for exit.");
     ConsoleWrapper.WriteText("run - runs current NPC and waits when you write 'exit' for exit. The current NPC is detected by locators.");
     ConsoleWrapper.WriteText("exit - ends running NPC.");
     ConsoleWrapper.WriteText("new <NPC name> - creates new NPC in new or existing worldspace. For creating NPC in existing worldspace runs command 'new' in worldspace directory.");
     ConsoleWrapper.WriteText("n - alias of 'new' command.");
     ConsoleWrapper.WriteText("version - prints current version of SymOntoClay.");
     ConsoleWrapper.WriteText("v - alias of 'version' command.");
 }
Exemplo n.º 2
0
        //private readonly Logger _logger = LogManager.GetCurrentClassLogger();
#endif

        public void Run(CLICommand command)
        {
            var wSpaceFile = RunCommandFilesSearcher.FindWSpaceFile(Directory.GetCurrentDirectory());

            var worldSpaceCreationSettings = new WorldSpaceCreationSettings()
            {
                ProjectName = command.ProjectName
            };

            if (wSpaceFile == null)
            {
                WorldSpaceCreator.CreateWithOutWSpaceFile(worldSpaceCreationSettings, Directory.GetCurrentDirectory()
                                                          , errorMsg => ConsoleWrapper.WriteError(errorMsg)
                                                          );
            }
            else
            {
                WorldSpaceCreator.CreateWithWSpaceFile(worldSpaceCreationSettings, wSpaceFile
                                                       , errorMsg => ConsoleWrapper.WriteError(errorMsg)
                                                       );
            }
        }
Exemplo n.º 3
0
 private void PrintHowToExitAndWait()
 {
     ConsoleWrapper.WriteText("Press any key for exit.");
     Console.ReadKey();
 }
Exemplo n.º 4
0
 private void PrintHeader()
 {
     ConsoleWrapper.WriteText("Copyright © 2020 Sergiy Tolkachov aka metatypeman");
 }
Exemplo n.º 5
0
 private void PrintAboutWrongCommandLine(CLICommand command)
 {
     ConsoleWrapper.WriteError("Unknown command!");
 }
Exemplo n.º 6
0
        public void Run(CLICommand command)
        {
            ConsoleWrapper.WriteText($"Loading {command.InputFile}...");

#if DEBUG
            //_logger.Info($"command = {command}");
#endif

            var targetFiles = RunCommandFilesSearcher.Run(command);

#if DEBUG
            //_logger.Info($"targetFiles = {targetFiles}");
#endif

            var invokingInMainThread = DefaultInvokerInMainThreadFactory.Create();

            var instance = WorldFactory.WorldInstance;
            world = instance;

            var settings = new WorldSettings();
            settings.EnableAutoloadingConvertors = true;

            settings.SharedModulesDirs = new List <string>()
            {
                targetFiles.SharedModulesDir
            };

            settings.ImagesRootDir = targetFiles.ImagesRootDir;

            settings.TmpDir = targetFiles.TmpDir;

            settings.HostFile = targetFiles.WorldFile;

            settings.InvokerInMainThread = invokingInMainThread;

            var logDir = Path.Combine(Environment.GetEnvironmentVariable("APPDATA"), "SymOntoClay", "CLI", "NpcLogs");

            settings.Logging = new LoggingSettings()
            {
                LogDir           = logDir,
                RootContractName = "Hi1",
                PlatformLoggers  = new List <IPlatformLogger>()
                {
                    new CLIPlatformLogger()
                },
                Enable = true,
                EnableRemoteConnection = true
            };

#if DEBUG
            //_logger.Info($"settings = {settings}");
#endif
            instance.SetSettings(settings);

            var platformListener = this;

            var npcSettings = new HumanoidNPCSettings();
            npcSettings.Id = "#020ED339-6313-459A-900D-92F809CEBDC5";
            //npcSettings.HostFile = Path.Combine(Directory.GetCurrentDirectory(), @"Source\Hosts\PeaceKeeper\PeaceKeeper.host");
            npcSettings.LogicFile       = targetFiles.LogicFile;
            npcSettings.HostListener    = platformListener;
            npcSettings.PlatformSupport = new PlatformSupportCLIStub();

#if DEBUG
            //_logger.Info($"npcSettings = {npcSettings}");
#endif
            var npc = instance.GetHumanoidNPC(npcSettings);

            instance.Start();

            ConsoleWrapper.WriteText("Press 'exit' and Enter for exit.");

            while (true)
            {
                var inputStr = Console.ReadLine();

                ConsoleWrapper.WriteText(inputStr);

                if (inputStr == "exit")
                {
                    ConsoleWrapper.WriteText("Are you sure? Type y/n and press Enter.");

                    inputStr = Console.ReadLine();

                    if (inputStr == "y")
                    {
                        break;
                    }
                }
                else
                {
                    ConsoleWrapper.WriteError("Unknown command! Press 'exit' and Enter for exit.");
                }
            }
        }
Exemplo n.º 7
0
 /// <inheritdoc/>
 public void WriteLnRawError(string message)
 {
     ConsoleWrapper.WriteError(message);
 }
Exemplo n.º 8
0
 /// <inheritdoc/>
 public void WriteLnRawWarning(string message)
 {
     ConsoleWrapper.WriteText(message);
 }
Exemplo n.º 9
0
 /// <inheritdoc/>
 public void WriteLnRawLogChannel(string message)
 {
     ConsoleWrapper.WriteLogChannel(message);
 }