示例#1
0
        // APPIO Generate command
        private static GenerateStrategy CreateGenerateStrategy(IFileSystem fileSystem, AbstractCertificateGenerator certificateGenerator)
        {
            // Generate command help first lines
            var generateHelpStrategyHelpText = new MessageLines
            {
                { string.Empty, HelpTextValues.GenerateFirstLine },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.GeneralUsage },
                { string.Empty, HelpTextValues.GenerateCallDescription }
            };

            // Generate command arguments
            var generateArguments = new MessageLines
            {
                { Constants.ImportCommandArguments.InformationModel, string.Empty },
                { Constants.ImportCommandArguments.Certificate, string.Empty }
            };

            // Generate command options
            var nameOption = new StringBuilder(Constants.GenerateCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.GenerateCommandOptions.VerboseName).ToString();
            var helpOption = new StringBuilder(Constants.GenerateCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.GenerateCommandOptions.VerboseHelp).ToString();

            var generateOptions = new MessageLines
            {
                { nameOption, HelpTextValues.OptionNameDescription },
                { helpOption, HelpTextValues.OptionHelpDescription },
                { Constants.GenerateCertificateCommandArguments.VerboseKeySize, HelpTextValues.GenerateCommandOptionKeySizeDescription },
                { Constants.GenerateCertificateCommandArguments.VerboseDays, HelpTextValues.GenerateCommandOptionDaysDescription },
                { Constants.GenerateCertificateCommandArguments.VerboseOrganization, HelpTextValues.GenerateCommandOptionOrganizationDescription }
            };

            // Generate help strategy
            var generateHelpStrategyData = new HelpData
            {
                CommandName       = Constants.GenerateCommandOptions.Help,
                HelpTextFirstLine = generateHelpStrategyHelpText,
                Arguments         = generateArguments,
                Options           = generateOptions,
                LogMessage        = LoggingText.AppioHelpForGenerateCommand,
                HelpText          = HelpTextValues.GenerateHelpArgumentCommandDescription,
            };

            var generateHelpStrategy = new HelpStrategy <GenerateStrategy>(generateHelpStrategyData);

            generateHelpStrategyData.CommandName = Constants.GenerateCommandOptions.VerboseHelp;

            var generateHelpStrategyVerbose = new HelpStrategy <GenerateStrategy>(generateHelpStrategyData);

            var modelValidator   = new ModelValidator(fileSystem);
            var nodesetGenerator = new NodesetGenerator(fileSystem, modelValidator);

            var generateSubCommands = new ICommand <GenerateStrategy>[]
            {
                new GenerateInformationModelStrategy(Constants.CommandName.GenerateInformationModel, fileSystem, modelValidator, nodesetGenerator),
                new GenerateCertificateStrategy(fileSystem, certificateGenerator),
                generateHelpStrategy,
                generateHelpStrategyVerbose
            };

            var generateStrategyCommandFactory = new CommandFactory <GenerateStrategy>(generateSubCommands, Constants.GenerateCommandOptions.Help);

            generateHelpStrategy.CommandFactory        = generateStrategyCommandFactory;
            generateHelpStrategyVerbose.CommandFactory = generateStrategyCommandFactory;

            return(new GenerateStrategy(generateStrategyCommandFactory));
        }
示例#2
0
        // APPIO New command
        private static NewStrategy CreateNewStrategy(IFileSystem fileSystem, AbstractCertificateGenerator certificateGenerator)
        {
            // New command help first lines
            var newHelpStrategyHelpText = new MessageLines
            {
                { string.Empty, HelpTextValues.NewFirstLine },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.GeneralUsage },
                { string.Empty, HelpTextValues.NewCallDescription },
            };

            // New command arguments
            var newArguments = new MessageLines
            {
                { Constants.NewCommandArguments.OpcuaApp, string.Empty },
                { Constants.NewCommandArguments.Sln, string.Empty }
            };

            // New command options
            var nameOption = new StringBuilder(Constants.NewCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerboseName).ToString();
            var helpOption = new StringBuilder(Constants.NewCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerboseHelp).ToString();
            var typeOption = new StringBuilder(Constants.NewCommandOptions.Type).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerboseType).ToString();
            var portOption = new StringBuilder(Constants.NewCommandOptions.Port).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerbosePort).ToString();
            var urlOption  = new StringBuilder(Constants.NewCommandOptions.Url).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerboseUrl).ToString();

            var newOptions = new MessageLines
            {
                { nameOption, HelpTextValues.NewCommandOptionNameDescription },
                { helpOption, HelpTextValues.OptionHelpDescription },
                { typeOption, HelpTextValues.NewCommandOptionTypeDescription },
                { portOption, HelpTextValues.NewCommandOptionPortDescription },
                { urlOption, HelpTextValues.NewCommandOptionUrlDescription },
                { Constants.NewCommandOptions.VerboseNoCert, HelpTextValues.NewCommandOptionNoCertDescription }
            };

            // New help strategy
            var newHelpStrategyData = new HelpData
            {
                CommandName       = Constants.NewCommandOptions.Help,
                HelpTextFirstLine = newHelpStrategyHelpText,
                Arguments         = newArguments,
                Options           = newOptions,
                LogMessage        = LoggingText.AppioHelpForNewCommandCalled,
                HelpText          = HelpTextValues.NewHelpArgumentCommandDescription,
            };

            var newHelpStrategy = new HelpStrategy <NewStrategy>(newHelpStrategyData);

            newHelpStrategyData.CommandName = Constants.NewCommandOptions.VerboseHelp;

            var newHelpVerboseStrategy = new HelpStrategy <NewStrategy>(newHelpStrategyData);

            var newStrategies = new ICommand <NewStrategy>[]
            {
                new NewSlnCommandStrategy(fileSystem),
                new NewOpcuaAppCommandStrategy(fileSystem, certificateGenerator),
                newHelpStrategy,
                newHelpVerboseStrategy,
            };

            var newStrategyCommandFactory = new CommandFactory <NewStrategy>(newStrategies, Constants.NewCommandOptions.Help);

            newHelpStrategy.CommandFactory        = newStrategyCommandFactory;
            newHelpVerboseStrategy.CommandFactory = newStrategyCommandFactory;

            return(new NewStrategy(newStrategyCommandFactory));
        }