private static CLICommand ParseRunCommand(string[] args)
        {
            var command = new CLICommand()
            {
                Kind = KindOfCLICommand.Run
            };

            switch (args.Length)
            {
            case 1:
                command.InputDir = Directory.GetCurrentDirectory();
                command.IsValid  = true;
                return(command);

            case 2:
            {
                var inputFile = args[1];

                command.InputFile = EVPath.Normalize(inputFile);
                command.IsValid   = true;
                return(command);
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(args.Length), args.Length, null);
            }
        }
        private static CLICommand ParseNewCommand(string[] args)
        {
            var command = new CLICommand()
            {
                Kind = KindOfCLICommand.New
            };

            switch (args.Length)
            {
            case 2:
            {
                command.ProjectName = args[1];
                command.IsValid     = true;
                return(command);
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(args.Length), args.Length, null);
            }
        }
Esempio n. 3
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)
                                                       );
            }
        }
Esempio n. 4
0
        //private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
#endif

        public static RunCommandFiles Run(CLICommand command)
        {
            if (string.IsNullOrWhiteSpace(command.InputFile))
            {
                if (string.IsNullOrWhiteSpace(command.InputDir))
                {
                    throw new NotImplementedException();
                }
                else
                {
                    var inputNpcFile = GetNpcFileNameInCurrentDir(command.InputDir);

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

                    if (string.IsNullOrWhiteSpace(inputNpcFile))
                    {
                        var wSpaceFile = FindWSpaceFile(command.InputDir);

                        if (wSpaceFile == null)
                        {
                            throw new NotImplementedException();
                        }

                        return(GetRunCommandFilesByWorldFile(wSpaceFile));
                    }
                    else
                    {
                        return(GetRunCommandFilesByInputFile(inputNpcFile));
                    }
                }
            }
            else
            {
                return(GetRunCommandFilesByInputFile(command.InputFile));
            }
        }
Esempio n. 5
0
 private void PrintAboutWrongCommandLine(CLICommand command)
 {
     ConsoleWrapper.WriteError("Unknown command!");
 }
Esempio 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.");
                }
            }
        }