Пример #1
0
        public ParameterDefinition(string name, string shortName  = "", string description = "", T defaultValue = default(T), bool isOptional = false,
                                   ConverterHandler <T> converter = null)
        {
            Name         = name;
            ShortName    = shortName;
            Description  = description;
            DefaultValue = defaultValue;
            IsOptional   = isOptional;
            Converter    = converter;

            if (!Equals(defaultValue, default(T)))
            {
                IsOptional = true;
            }
        }
            public ItemShowInvCommand()
            {
                base.Aliases = new string[]
                {
                    "showinv"
                };
                base.RequiredRole  = RoleEnum.Moderator;
                base.Description   = "Show items of the target into your inventory";
                base.ParentCommand = typeof(ItemCommand);
                string arg_57_1 = "target";
                string arg_57_2 = "t";
                string arg_57_3 = "Where items will be search";
                ConverterHandler <Character> characterConverter = ParametersConverter.CharacterConverter;

                base.AddParameter <Character>(arg_57_1, arg_57_2, arg_57_3, null, true, characterConverter);
            }
Пример #3
0
        public LearnMonsterSpellCommand()
        {
            base.Aliases = new string[]
            {
                "learnmonster"
            };
            base.RequiredRole  = RoleEnum.GameMaster;
            base.ParentCommand = typeof(SpellsCommands);
            base.Description   = "Learn the given spell";
            string arg_57_1 = "monster";
            string arg_57_2 = "monster";
            string arg_57_3 = "Target monster to learn spells";
            ConverterHandler <MonsterTemplate> monsterTemplateConverter = ParametersConverter.MonsterTemplateConverter;

            base.AddParameter <MonsterTemplate>(arg_57_1, arg_57_2, arg_57_3, null, true, monsterTemplateConverter);
            base.AddTargetParameter(true, "Defined target");
        }
            public ItemListCommand()
            {
                base.Aliases = new string[]
                {
                    "list",
                    "ls"
                };
                base.RequiredRole  = RoleEnum.GameMaster;
                base.Description   = "Lists loaded items or items from an inventory with a search pattern";
                base.ParentCommand = typeof(ItemCommand);
                base.AddParameter <string>("pattern", "p", "Search pattern (see docs)", "*", false, null);
                string arg_7B_1 = "target";
                string arg_7B_2 = "t";
                string arg_7B_3 = "Where items will be search";
                ConverterHandler <Character> characterConverter = ParametersConverter.CharacterConverter;

                base.AddParameter <Character>(arg_7B_1, arg_7B_2, arg_7B_3, null, true, characterConverter);
                base.AddParameter <int>("page", "page", "Page number of the list (starts at 0)", 0, true, null);
            }
        public AccountCreateCommand()
        {
            base.Aliases = new string[]
            {
                "create",
                "cr",
                "new"
            };
            base.ParentCommand = typeof(AccountCommands);
            base.RequiredRole  = RoleEnum.Administrator;
            base.Description   = "Create a new account.";
            base.AddParameter <string>("accountname", "name", "Name of the created account", null, false, null);
            base.AddParameter <string>("password", "pass", "Password of the created accont", null, false, null);
            ConverterHandler <RoleEnum> roleConverter = ParametersConverter.RoleConverter;

            base.AddParameter <RoleEnum>("role", "role", "Role of the created account. See RoleEnum", RoleEnum.Player, false, roleConverter);
            base.AddParameter <string>("question", "quest", "Secret question", "dummy?", false, null);
            base.AddParameter <string>("answer", "answer", "Answer to the secret question", "dummy!", false, null);
        }
Пример #6
0
        static void Main(string[] args)
        {
            Options           options = new Options();
            CommandLineParser parser  = new CommandLineParser(options);

            parser.Parse();
            Console.WriteLine(parser.UsageInfo.GetHeaderAsString(78));

            if (options.Help)
            {
                Console.WriteLine(parser.UsageInfo.GetOptionsAsString(78));
                Console.ReadLine();
            }
            else if (parser.HasErrors)
            {
                Console.WriteLine(parser.UsageInfo.GetErrorsAsString(78));
                Console.ReadLine();
            }
            Console.WriteLine($"path: {options.FilePath}");
            Console.WriteLine($"convertTo: {options.ConvertTo}");

            var  container      = BuildContainer();
            var  csvToJson      = container.Resolve <IConvertCsvToJson>();
            var  csvToXml       = container.Resolve <IConvertCsvToXml>();
            var  convertHandler = new ConverterHandler(csvToJson, csvToXml);
            bool success        = convertHandler.Convert(options);

            if (success)
            {
                Console.WriteLine("Your file has been converted and can be found in the same directory");
            }
            else
            {
                Console.WriteLine("Something went wrong during conversion");
            }

            Console.ReadLine();
        }
Пример #7
0
 public void AddParameter <T>(string name, string shortName = "", string description = "", T defaultValue = default(T), bool isOptional = false, ConverterHandler <T> converter = null)
 {
     this.Parameters.Add(new ParameterDefinition <T>(name, shortName, description, defaultValue, isOptional, converter));
 }
Пример #8
0
 public ParameterDefinition(string name, string shortName = "", string description = "", T defaultValue = default(T), bool isOptional = false, ConverterHandler <T> converter = null)
 {
     this.Name         = name;
     this.ShortName    = shortName;
     this.Description  = description;
     this.DefaultValue = defaultValue;
     this.IsOptional   = isOptional;
     this.Converter    = converter;
     if (!object.Equals(defaultValue, default(T)))
     {
         this.IsOptional = true;
     }
 }