Example #1
0
        public void Run(string[] args)
        {
            // Title
            commandLineApplication.FullName = "WorkplaceX.Cli";
            commandLineApplication.HelpOption("-h | --help"); // Command line interface help (to show commands)
            commandLineApplication.VersionOption("-v | --version", UtilCli.Version);

            // Register command new project
            commandLineApplication.Command("new", (configuration) =>
            {
                configuration.Description = "Create new project";
                configuration.OnExecute(() => Command(configuration, CommandNewProject));
            });

            // Register command templateZip
            if (UtilCli.FolderNameFrameworkSln != null)
            {
                var folderNameTemplate = new Uri(new Uri(UtilCli.FolderNameFrameworkSln), "Framework.Template/").AbsolutePath;
                if (Directory.Exists(folderNameTemplate))
                {
                    commandLineApplication.Command("templateZip", (configuration) =>
                    {
                        configuration.Description = "Zip folder Framework.Template/ before pack.";
                        configuration.OnExecute(() => Command(configuration, CommandTemplateZip));
                    });
                }
            }

            // Show list of available commands
            if (args.Length > 0)
            {
                commandLineApplication.Execute("-h"); // Show list of available commands.
            }

            // Debug
            Console.WriteLine("FolderNameAssembly=" + UtilCli.FolderNameAssembly);
            Console.WriteLine("FolderNameCurrent=" + UtilCli.FolderNameCurrent);
            Console.WriteLine("FolderNameFrameworkSln=" + UtilCli.FolderNameFrameworkSln);
            Console.WriteLine("FolderNameContent=" + UtilCli.FolderNameContent);
            Console.WriteLine("FolderNameAppCliExe=" + UtilCli.FolderNameAppCliExe);
            Console.WriteLine("FolderNameAppCliCsproj=" + UtilCli.FolderNameAppCliCsproj);

            // Execute command
            try
            {
                commandLineApplication.Execute(args);
            }
            catch (Exception exception) // For example unrecognized option
            {
                UtilCli.ConsoleWriteLineError(exception);
            }
        }