예제 #1
0
 public MessageLines(MessageLines messages)
 {
     foreach (var msg in messages)
     {
         Add(msg.Key, msg.Value);
     }
 }
예제 #2
0
 public void Add(MessageLines lines)
 {
     foreach (var line in lines)
     {
         Add(line.Key, line.Value);
     }
 }
            public CommandResult Execute(IEnumerable <string> inputParams)
            {
                AppioLogger.Warn(LoggingText.UnknownCommandCalled);
                var outputMessages = new MessageLines();

                outputMessages.Add(Constants.CommandResults.Failure, string.Empty);
                return(new CommandResult(false, outputMessages));
            }
예제 #4
0
        // APPIO Publish command
        private static PublishStrategy CreatePublishStrategy(IFileSystem fileSystem)
        {
            // Publish command help first lines
            var publishHelpStrategyHelpText = new MessageLines
            {
                { string.Empty, HelpTextValues.PublishFirstLine },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.GeneralUsage },
                { string.Empty, HelpTextValues.PublishCallDescription }
            };

            // Publish command options
            var nameOption     = new StringBuilder(Constants.PublishCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.PublishCommandOptions.VerboseName).ToString();
            var helpOption     = new StringBuilder(Constants.PublishCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.PublishCommandOptions.VerboseHelp).ToString();
            var publishOptions = new MessageLines
            {
                { nameOption, HelpTextValues.OptionNameDescription },
                { helpOption, HelpTextValues.OptionHelpDescription }
            };

            // Publish help strategy
            var publishHelpStrategyData = new HelpData
            {
                CommandName       = Constants.PublishCommandOptions.Help,
                HelpTextFirstLine = publishHelpStrategyHelpText,
                Options           = publishOptions,
                LogMessage        = LoggingText.OpcuaappPublishHelpCalled,
                HelpText          = HelpTextValues.PublishHelpArgumentCommandDescription,
            };

            var publishHelpStrategy = new HelpStrategy <PublishStrategy>(publishHelpStrategyData);

            publishHelpStrategyData.CommandName = Constants.PublishCommandOptions.VerboseHelp;

            var publishHelpVerboseStrategy = new HelpStrategy <PublishStrategy>(publishHelpStrategyData);

            var publishStrategies = new ICommand <PublishStrategy>[]
            {
                new PublishNameStrategy(Constants.PublishCommandOptions.Name, fileSystem),
                new PublishNameStrategy(Constants.PublishCommandOptions.VerboseName, fileSystem),
                publishHelpStrategy,
                publishHelpVerboseStrategy,
            };

            var publishStrategyCommandFactory = new CommandFactory <PublishStrategy>(publishStrategies, Constants.PublishCommandOptions.Help);

            publishHelpStrategy.CommandFactory        = publishStrategyCommandFactory;
            publishHelpVerboseStrategy.CommandFactory = publishStrategyCommandFactory;

            return(new PublishStrategy(publishStrategyCommandFactory));
        }
예제 #5
0
        // APPIO Build command
        private static BuildStrategy CreateBuildStrategy(IFileSystem fileSystem)
        {
            // Build command help first lines
            var buildHelpStrategyHelpText = new MessageLines
            {
                { string.Empty, HelpTextValues.BuildFirstLine },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.GeneralUsage },
                { string.Empty, HelpTextValues.BuildCallDescription }
            };

            // Build command options
            var nameOption   = new StringBuilder(Constants.BuildCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.BuildCommandOptions.VerboseName).ToString();
            var helpOption   = new StringBuilder(Constants.BuildCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.BuildCommandOptions.VerboseHelp).ToString();
            var buildOptions = new MessageLines
            {
                { nameOption, HelpTextValues.OptionNameDescription },
                { helpOption, HelpTextValues.OptionHelpDescription }
            };

            // Build help strategy
            var buildHelpStrategyData = new HelpData
            {
                CommandName       = Constants.BuildCommandOptions.Help,
                HelpTextFirstLine = buildHelpStrategyHelpText,
                Options           = buildOptions,
                LogMessage        = LoggingText.AppioHelpForBuildCommandCalled,
                HelpText          = HelpTextValues.BuildHelpArgumentCommandDescription,
            };

            var buildHelpStrategy = new HelpStrategy <BuildStrategy>(buildHelpStrategyData);

            buildHelpStrategyData.CommandName = Constants.BuildCommandOptions.VerboseHelp;

            var buildHelpVerboseStrategy = new HelpStrategy <BuildStrategy>(buildHelpStrategyData);

            var buildStrategies = new ICommand <BuildStrategy>[]
            {
                new BuildNameStrategy(Constants.BuildCommandOptions.Name, fileSystem),
                new BuildNameStrategy(Constants.BuildCommandOptions.VerboseName, fileSystem),
                buildHelpStrategy,
                buildHelpVerboseStrategy
            };

            var buildStrategyCommandFactory = new CommandFactory <BuildStrategy>(buildStrategies, Constants.BuildCommandOptions.Help);

            buildHelpStrategy.CommandFactory        = buildStrategyCommandFactory;
            buildHelpVerboseStrategy.CommandFactory = buildStrategyCommandFactory;

            return(new BuildStrategy(buildStrategyCommandFactory));
        }
예제 #6
0
        // APPIO Deploy command
        private static DeployStrategy CreateDeployStrategy(IFileSystem fileSystem)
        {
            // Deploy command help first lines
            var deployHelpStrategyHelpText = new MessageLines
            {
                { string.Empty, HelpTextValues.DeployFirstLine },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.GeneralUsage },
                { string.Empty, HelpTextValues.DeployCallDescription }
            };

            // Deploy command options
            var nameOption    = new StringBuilder(Constants.DeployCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.DeployCommandOptions.VerboseName).ToString();
            var helpOption    = new StringBuilder(Constants.DeployCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.DeployCommandOptions.VerboseHelp).ToString();
            var deployOptions = new MessageLines
            {
                { nameOption, HelpTextValues.OptionNameDescription },
                { helpOption, HelpTextValues.OptionHelpDescription }
            };

            var deployHelpStrategyData = new HelpData
            {
                CommandName       = Constants.DeployCommandOptions.Help,
                HelpTextFirstLine = deployHelpStrategyHelpText,
                Options           = deployOptions,
                LogMessage        = LoggingText.AppioHelpForDeployCommandCalled,
                HelpText          = HelpTextValues.DeployHelpArgumentCommandDescription,
            };

            var deployHelpStrategy = new HelpStrategy <DeployStrategy>(deployHelpStrategyData);

            deployHelpStrategyData.CommandName = Constants.DeployCommandOptions.VerboseHelp;

            var deployVerboseHelpStrategy = new HelpStrategy <DeployStrategy>(deployHelpStrategyData);

            var deployStrategies = new ICommand <DeployStrategy>[]
            {
                new DeployNameStrategy(Constants.DeployCommandOptions.Name, fileSystem),
                new DeployNameStrategy(Constants.DeployCommandOptions.VerboseName, fileSystem),
                deployHelpStrategy,
                deployVerboseHelpStrategy
            };

            var deployStrategyCommandFactory = new CommandFactory <DeployStrategy>(deployStrategies, Constants.DeployCommandOptions.Help);

            deployHelpStrategy.CommandFactory        = deployStrategyCommandFactory;
            deployVerboseHelpStrategy.CommandFactory = deployStrategyCommandFactory;

            return(new DeployStrategy(deployStrategyCommandFactory));
        }
예제 #7
0
        private static HelpData CreateHelpData(string commandName)
        {
            // generic help data
            var helpOption = new StringBuilder(Constants.CommandName.HelpDash).Append(Constants.HelpOptionSeparator).Append(Constants.CommandName.HelpDashVerbose).ToString();
            var helpStrategyFirstLineText = new MessageLines
            {
                { string.Empty, HelpTextValues.HelpStartWelcome },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.HelpStartDocuLink },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.GeneralUsage },
                { string.Empty, HelpTextValues.HelpStartUsageDescription },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.HelpStartAppioOptions },
                { helpOption, HelpTextValues.HelpCommand },
                { Constants.CommandName.Version, HelpTextValues.VersionCommand },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.HelpStartCommand },
                { Constants.CommandName.Build, HelpTextValues.BuildCommand },
                { Constants.CommandName.Clean, HelpTextValues.CleanCommand },
                { Constants.CommandName.Deploy, HelpTextValues.DeployCommand },
                { Constants.CommandName.Generate, HelpTextValues.GenerateCommand },
                { Constants.CommandName.Help, HelpTextValues.HelpCommand },
                { Constants.CommandName.Import, HelpTextValues.ImportCommand },
                { Constants.CommandName.New, HelpTextValues.NewCommand },
                { Constants.CommandName.Publish, HelpTextValues.PublishCommand },
                { Constants.CommandName.Reference, HelpTextValues.ReferenceCommand },
                { Constants.CommandName.Sln, HelpTextValues.SlnCommand }
            };

            var helpStrategyLastLineText = new MessageLines
            {
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.HelpEndCommand },
            };

            return(new HelpData
            {
                CommandName = commandName,
                HelpTextFirstLine = helpStrategyFirstLineText,
                HelpTextLastLine = helpStrategyLastLineText,
                LogMessage = LoggingText.AppioHelpCalled,
                HelpText = HelpTextValues.HelpCommand,
            });
        }
예제 #8
0
        // APPIO Reference command
        private static ReferenceStrategy CreateReferenceStrategy(IFileSystem fileSystem)
        {
            // Reference command help first lines
            var referenceHelpStrategyHelpText = new MessageLines
            {
                { string.Empty, HelpTextValues.ReferenceFirstLine },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.GeneralUsage },
                { string.Empty, HelpTextValues.ReferenceCallDescription }
            };

            // Reference command arguments
            var referenceArguments = new MessageLines
            {
                { Constants.ReferenceCommandArguments.Add, string.Empty },
                { Constants.ReferenceCommandArguments.Remove, string.Empty }
            };

            // Reference command options
            var clientOption = new StringBuilder(Constants.ReferenceCommandOptions.Client).Append(Constants.HelpOptionSeparator).Append(Constants.ReferenceCommandOptions.VerboseClient).ToString();
            var serverOption = new StringBuilder(Constants.ReferenceCommandOptions.Server).Append(Constants.HelpOptionSeparator).Append(Constants.ReferenceCommandOptions.VerboseServer).ToString();
            var helpOption   = new StringBuilder(Constants.ReferenceCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.ReferenceCommandOptions.VerboseHelp).ToString();

            var referenceOptions = new MessageLines
            {
                { clientOption, HelpTextValues.ReferenceCommandOptionClientDescription },
                { serverOption, HelpTextValues.ReferenceCommandOptionServerDescription },
                { helpOption, HelpTextValues.OptionHelpDescription },
            };

            // Reference help strategy
            var referenceHelpStrategyData = new HelpData
            {
                CommandName       = Constants.ReferenceCommandOptions.Help,
                HelpTextFirstLine = referenceHelpStrategyHelpText,
                Arguments         = referenceArguments,
                Options           = referenceOptions,
                LogMessage        = LoggingText.AppioHelpForReferenceCommand,
                HelpText          = HelpTextValues.ReferenceHelpArgumentCommandDescription,
            };

            var referenceHelpStrategy = new HelpStrategy <ReferenceStrategy>(referenceHelpStrategyData);

            referenceHelpStrategyData.CommandName = Constants.ReferenceCommandOptions.VerboseHelp;

            var referenceHelpVerboseStrategy = new HelpStrategy <ReferenceStrategy>(referenceHelpStrategyData);

            var referenceStrategies = new ICommand <ReferenceStrategy>[]
            {
                new ReferenceAddCommandStrategy(fileSystem),
                new ReferenceRemoveCommandStrategy(fileSystem),
                referenceHelpStrategy,
                referenceHelpVerboseStrategy,
            };

            var referenceStrategyCommandFactory = new CommandFactory <ReferenceStrategy>(referenceStrategies, Constants.ReferenceCommandOptions.Help);

            referenceHelpStrategy.CommandFactory        = referenceStrategyCommandFactory;
            referenceHelpVerboseStrategy.CommandFactory = referenceStrategyCommandFactory;

            return(new ReferenceStrategy(referenceStrategyCommandFactory));
        }
예제 #9
0
        // APPIO Sln command
        private static SlnStrategy CreateSlnStrategy(IFileSystem fileSystem)
        {
            // Sln command help first lines
            var slnHelpStrategyHelpText = new MessageLines
            {
                { string.Empty, HelpTextValues.SlnFirstLine },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.GeneralUsage },
                { string.Empty, HelpTextValues.SlnCallDescription }
            };

            // Sln command arguments
            var slnArguments = new MessageLines
            {
                { Constants.SlnCommandArguments.Add, HelpTextValues.SlnCommandArgumentAddDescription },
                { Constants.SlnCommandArguments.Remove, HelpTextValues.SlnCommandArtgumentRemoveDescription },
                { Constants.SlnCommandArguments.Build, HelpTextValues.SlnCommandArtgumentBuildDescription },
                { Constants.SlnCommandArguments.Publish, HelpTextValues.SlnCommandArtgumentPublishDescription },
                { Constants.SlnCommandArguments.Deploy, HelpTextValues.SlnCommandArtgumentDeployDescription }
            };

            // Sln command options
            var solutionOption = new StringBuilder(Constants.SlnCommandOptions.Solution).Append(Constants.HelpOptionSeparator).Append(Constants.SlnCommandOptions.VerboseSolution).ToString();
            var projectOption  = new StringBuilder(Constants.SlnCommandOptions.Project).Append(Constants.HelpOptionSeparator).Append(Constants.SlnCommandOptions.VerboseProject).ToString();
            var helpOption     = new StringBuilder(Constants.SlnCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.SlnCommandOptions.VerboseHelp).ToString();

            var slnOptions = new MessageLines
            {
                { solutionOption, HelpTextValues.SlnCommandOptionSolutionDescription },
                { projectOption, HelpTextValues.SlnCommandOptionProjectDescription },
                { helpOption, HelpTextValues.OptionHelpDescription },
            };

            // Sln help strategy
            var slnHelpStrategyData = new HelpData
            {
                CommandName       = Constants.SlnCommandOptions.Help,
                HelpTextFirstLine = slnHelpStrategyHelpText,
                Arguments         = slnArguments,
                Options           = slnOptions,
                LogMessage        = LoggingText.AppioHelpForSlnCommand,
                HelpText          = HelpTextValues.SlnHelpArgumentCommandDescription,
            };

            var slnHelpStrategy = new HelpStrategy <SlnStrategy>(slnHelpStrategyData);

            slnHelpStrategyData.CommandName = Constants.SlnCommandOptions.VerboseHelp;

            var slnHelpVerboseStrategy = new HelpStrategy <SlnStrategy>(slnHelpStrategyData);

            var SlnBuildCommandData = new SlnOperationData();

            SlnBuildCommandData.CommandName          = Constants.CommandName.Build;
            SlnBuildCommandData.FileSystem           = fileSystem;
            SlnBuildCommandData.Subcommand           = new BuildNameStrategy(Constants.CommandName.Build, fileSystem);
            SlnBuildCommandData.SuccessLoggerMessage = LoggingText.SlnBuildSuccess;
            SlnBuildCommandData.SuccessOutputMessage = OutputText.SlnBuildSuccess;
            SlnBuildCommandData.HelpText             = HelpTextValues.SlnBuildNameArgumentCommandDescription;

            var SlnDeployCommandData = new SlnOperationData();

            SlnDeployCommandData.CommandName          = Constants.CommandName.Deploy;
            SlnDeployCommandData.FileSystem           = fileSystem;
            SlnDeployCommandData.Subcommand           = new DeployNameStrategy(Constants.CommandName.Deploy, fileSystem);
            SlnDeployCommandData.SuccessLoggerMessage = LoggingText.SlnDeploySuccess;
            SlnDeployCommandData.SuccessOutputMessage = OutputText.SlnDeploySuccess;
            SlnDeployCommandData.HelpText             = HelpTextValues.SlnDeployNameArgumentCommandDescription;

            var SlnPublishCommandData = new SlnOperationData();

            SlnPublishCommandData.CommandName          = Constants.CommandName.Publish;
            SlnPublishCommandData.FileSystem           = fileSystem;
            SlnPublishCommandData.Subcommand           = new PublishNameStrategy(Constants.CommandName.Publish, fileSystem);
            SlnPublishCommandData.SuccessLoggerMessage = LoggingText.SlnPublishSuccess;
            SlnPublishCommandData.SuccessOutputMessage = OutputText.SlnPublishSuccess;
            SlnPublishCommandData.HelpText             = HelpTextValues.SlnPublishNameArgumentCommandDescription;

            var slnStrategies = new ICommand <SlnStrategy>[]
            {
                new SlnAddCommandStrategy(fileSystem),
                new SlnOperationCommandStrategy(SlnBuildCommandData),
                new SlnOperationCommandStrategy(SlnDeployCommandData),
                new SlnOperationCommandStrategy(SlnPublishCommandData),
                new SlnRemoveCommandStrategy(fileSystem),
                slnHelpStrategy,
                slnHelpVerboseStrategy,
            };

            var slnStrategyCommandFactory = new CommandFactory <SlnStrategy>(slnStrategies, Constants.SlnCommandOptions.Help);

            slnHelpStrategy.CommandFactory        = slnStrategyCommandFactory;
            slnHelpVerboseStrategy.CommandFactory = slnStrategyCommandFactory;

            return(new SlnStrategy(slnStrategyCommandFactory));
        }
예제 #10
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));
        }
예제 #11
0
        // APPIO Import Strategy
        private static ImportStrategy CreateImportStrategy(IFileSystem fileSystem)
        {
            // Import command help first lines
            var importHelpStrategyHelpText = new MessageLines
            {
                { string.Empty, HelpTextValues.ImportFirstLine },
                { string.Empty, string.Empty },
                { string.Empty, HelpTextValues.GeneralUsage },
                { string.Empty, HelpTextValues.ImportCallDescription }
            };

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

            // Import command options
            var nameOption         = new StringBuilder(Constants.ImportCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerboseName).ToString();
            var pathOption         = new StringBuilder(Constants.ImportCommandOptions.Path).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerbosePath).ToString();
            var typesOption        = new StringBuilder(Constants.ImportCommandOptions.Types).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerboseTypes).ToString();
            var helpOption         = new StringBuilder(Constants.ImportCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerboseHelp).ToString();
            var sampleOption       = new StringBuilder(Constants.ImportCommandOptions.Sample).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerboseSample).ToString();
            var keyOption          = new StringBuilder(Constants.ImportCertificateCommandArguments.Key).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCertificateCommandArguments.VerboseKey).ToString();
            var certiciateOption   = new StringBuilder(Constants.ImportCertificateCommandArguments.Certificate).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCertificateCommandArguments.VerboseCertificate).ToString();
            var clientServerOption = new StringBuilder(Constants.ImportCertificateCommandArguments.VerboseClient).Append(" or ").Append(Constants.ImportCertificateCommandArguments.VerboseServer).ToString();

            var importOptions = new MessageLines
            {
                { nameOption, HelpTextValues.OptionNameDescription },
                { pathOption, HelpTextValues.ImportCommandOptionPathDescription },
                { typesOption, HelpTextValues.ImportCommandOptionTypesDescription },
                { helpOption, HelpTextValues.OptionHelpDescription },
                { sampleOption, HelpTextValues.ImportCommandOptionSampleDescription },
                { keyOption, HelpTextValues.ImportCommandOptionKeyDescription },
                { certiciateOption, HelpTextValues.ImportCommandOptionCertificateDescription },
                { clientServerOption, HelpTextValues.ImportCommandOptionClientServerDescription }
            };

            // Import help strategy
            var importHelpStrategyData = new HelpData
            {
                CommandName       = Constants.ImportCommandOptions.Help,
                HelpTextFirstLine = importHelpStrategyHelpText,
                Arguments         = importArguments,
                Options           = importOptions,
                LogMessage        = LoggingText.AppioHelpForImportInformationModel,
                HelpText          = HelpTextValues.ImportHelpArgumentCommandDescription,
            };

            var importHelpStrategy = new HelpStrategy <ImportStrategy>(importHelpStrategyData);

            importHelpStrategyData.CommandName = Constants.ImportCommandOptions.VerboseHelp;

            var importHelpStrategyVerbose = new HelpStrategy <ImportStrategy>(importHelpStrategyData);
            var importCommands            = new ICommand <ImportStrategy>[]
            {
                new ImportInformationModelCommandStrategy(fileSystem, new ModelValidator(fileSystem)),
                new ImportCertificateStrategy(fileSystem),
                importHelpStrategy,
                importHelpStrategyVerbose
            };

            var importStrategyCommandFactory = new CommandFactory <ImportStrategy>(importCommands, Constants.ImportCommandOptions.Help);

            importHelpStrategy.CommandFactory        = importStrategyCommandFactory;
            importHelpStrategyVerbose.CommandFactory = importStrategyCommandFactory;

            return(new ImportStrategy(importStrategyCommandFactory));
        }
예제 #12
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));
        }