Exemple #1
0
        public static void Main(string[] args)
        {
            // get configuration
            var metadataService = new DotvvmProjectMetadataService();
            var metadata        = metadataService.FindInDirectory(Directory.GetCurrentDirectory());

            if (metadata == null)
            {
                Console.WriteLine("No DotVVM project metadata file (.dotvvm.json) was found on current path.");
                if (ConsoleHelpers.AskForYesNo("Is the current directory the root directory of DotVVM project?"))
                {
                    Console.WriteLine();
                    metadata = metadataService.CreateDefaultConfiguration(Directory.GetCurrentDirectory());
                    metadataService.Save(metadata);
                }
                else
                {
                    Console.WriteLine("There is no DotVVM project metadata file!");
                    Environment.Exit(1);
                }
            }

            // find applicable command
            var commands = new CommandBase[]
            {
                new AddPageCommand(),
                new AddMasterPageCommand(),
                new AddViewModelCommand(),
                new AddControlCommand(),
                new AddNswagCommand(),
                new RegenNswagCommand()

                //new GenerateUiTestStubCommand()
            };
            var arguments = new Arguments(args);
            var command   = commands.FirstOrDefault(c => c.CanHandle(arguments, metadata));

            // execute the command
            try
            {
                if (command != null)
                {
                    command.Handle(arguments, metadata);

                    // save project metadata
                    metadataService.Save(metadata);
                }
                else
                {
                    throw new InvalidCommandUsageException("Unknown command!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message);
                Console.Error.WriteLine(ex.ToString());
                Environment.Exit(1);
            }
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            // get configuration
            var metadataService = new DotvvmProjectMetadataService();
            var metadata        = metadataService.FindInDirectory(Directory.GetCurrentDirectory());

            if (metadata == null)
            {
                Console.WriteLine("No DotVVM project metadata was found on current path.");
                Console.WriteLine("Is the current directory the root directory of DotVVM project? [y] or [n]");
                if (Console.ReadKey().Key == ConsoleKey.Y)
                {
                    Console.WriteLine();
                    metadata = metadataService.CreateDefaultConfiguration(Directory.GetCurrentDirectory());
                    metadataService.Save(metadata);
                }
                else
                {
                    Console.WriteLine();
                    Environment.Exit(1);
                }
            }

            // find applicable command
            var commands = new CommandBase[]
            {
                new CreateProjectCommand(),

                new AddPageCommand(),
                new AddMasterPageCommand(),
                new AddViewModelCommand(),
                new AddControlCommand(),

                new GenerateUiTestStubCommand()
            };
            var arguments = new Arguments(args);
            var command   = commands.FirstOrDefault(c => c.CanHandle(arguments, metadata));

            // execute the command
            if (command != null)
            {
                command.Handle(arguments, metadata);

                // save project metadata
                metadataService.Save(metadata);
            }
            else
            {
                throw new InvalidCommandUsageException("Invalid command!");
            }
        }