예제 #1
0
        static void Main(string[] args)
        {
            var runCommand     = Kingpin.Command("run", "run a command").IsDefault();
            var runUrlCommand  = runCommand.Command("url", "Run a URL");
            var runUrlArgument = runUrlCommand.Argument("url", "the url to run").IsRequired().IsUrl();

            var configuration = new ConfigurationBuilder().AddKingpinNetCommandLine(args).Build();

            if (configuration["Command"] == runCommand.Path)
            {
                // Only run command specified on command line
            }

            if (configuration["Command"] == runCommand.Path)
            {
                // run url https://something specified on commandline
            }

            if (runUrlCommand.IsSet)
            {
                // run url https://something specified on commandline
                var url = runUrlArgument.Value;
            }
            Console.ReadLine();
        }
        public void Setup()
        {
            cuchillo = new Arma("Tramontina", 0);
            nuevemm  = new Arma("Fiat", 15);
            dagas    = new Arma("Daguimax", 0);
            subfusil = new Arma("Ametrallamigo", 30);

            armasg = new List <Arma>()
            {
                cuchillo, nuevemm
            };
            armasnoir = new List <Arma>()
            {
                cuchillo, nuevemm, dagas, subfusil
            };

            kingpin = new Kingpin();

            generico = new Traje(10, armasg);
            depeter  = new Traje(13, armasg);
            denoir   = new Traje(11, armasnoir);

            peterparker  = new PeterParker(depeter, 15);     // fuerza 28
            spidernoir   = new SpiderNoir(denoir, 10);       // fuerza 25
            spidergwen   = new SpiderGwen(generico, 9, 3);   // fuerza 12
            milesmorales = new MilesMorales(generico, 8, 7); // fuerza 15

            elequipo = new List <Spiderman>()
            {
                peterparker, spidernoir, spidergwen, milesmorales
            };
            spiderTeam = new SpiderTeam(elequipo, kingpin);
        }
 public void Setup()
 {
     Parker  = new PeterParker(400, 400);
     Gwen    = new SpiderGwen(10, 8);
     Noir    = new SpidermanNoir(20, 20, 4);
     Morales = new MilesMorales(5, 20);
     kingpin = new Kingpin();
 }
예제 #4
0
        static void Main(string[] args)
        {
            Kingpin
            .Version("1.0")
            .Author("Peter Andersen")
            .ApplicationName("curl")
            .Help("An example implementation of curl.")
            .ExitOnHelp()
            .ShowHelpOnParsingErrors()
            .Log((serverity, message, exception) => {
                Console.WriteLine($"[{serverity}]\t{message}");
                if (exception != null)
                {
                    Console.WriteLine($"\t{exception}");
                }
            });

            var timeout = Kingpin.Flag("timeout", "Set connection timeout.").Short('t').Default("5s"); // .Duration()
            var headers = Kingpin.Flag("headers", "Add HTTP headers to the request.").Short('H');      // .PlaceHolder("HEADER=VALUE");

            var getCategory = Kingpin.Category("Get", "Category for all the GET commands:");

            var get         = getCategory.Command("get", "GET a resource.").IsDefault();
            var getFlag     = get.Flag("test", "Test flag").IsBool();
            var getUrl      = get.Command("url", "Retrieve a URL.").IsDefault();
            var getUrlUrl   = getUrl.Argument("url", "URL to GET.").IsRequired().IsUrl().SetSuggestions("http://localhost", "http://192.168.1.1", "http://0.0.0.0");
            var getFile     = get.Command("file", "Retrieve a file.");
            var getFileFile = getFile.Argument("file", "File to retrieve.").IsRequired(); // .ExistingFile()

            var post           = getCategory.Command("post", "POST a resource.");
            var postData       = post.Flag("data", "Key-value data to POST").Short('d');     // .PlaceHolder("KEY:VALUE").StringMap()
            var postBinaryFile = post.Flag("data-binary", "File with binary data to POST."); // .IsFile();
            var postUrl        = post.Argument("url", "URL to POST to.").IsRequired().IsUrl().SetSuggestions("http://localhost", "http://192.168.1.1", "http://0.0.0.0");

            var list           = Kingpin.Command("list", "LIST a resource.");
            var listData       = list.Flag("data", "Key-value data to LIST").Short('d');     // .PlaceHolder("KEY:VALUE").StringMap()
            var listBinaryFile = list.Flag("data-binary", "File with binary data to LIST."); // .IsFile();
            var listUrl        = list.Argument("url", "URL to LIST to.").IsRequired().IsUrl().SetSuggestions("http://localhost", "http://192.168.1.1", "http://0.0.0.0");

            var configuration = new ConfigurationBuilder().AddKingpinNetCommandLine(args).Build();

            switch (configuration["command"])
            {
            case "get:url":
                Console.WriteLine($"Getting URL {configuration["get:url:url"]}");
                break;

            case "post":
                Console.WriteLine($"Posting to URL {configuration["post:url"]}");
                break;

            default:
                throw new Exception("Didn't understand commandline");
            }
        }
 public void DerrotarAKingPinYVuelveACasaGwen()
 {
     for (int i = 0; i < 11; i++) // Kingpin es debidamente molido a palos 11 veces, así tiene menos de 0 de vida
     {
         spiderTeam.PelearConKingpin();
     }
     kingpin = spiderTeam.Kingpin;
     spiderTeam.VolverACasa();
     spiderTeam.Equipo.OrderBy(spider => spider.Poder());
     Assert.AreEqual(15, spiderTeam.Equipo.First().Poder()); // se comprueba que el de
     //menor fuerza es ahora Miles Morales con 15
 }
        public void Setup()
        {
            peter = new Peter_Parker(10, new Traje(15, null));
            noir  = new Spider_Noir(10, new Traje(10, new List <Arma>()
            {
                new Arma("papaia", 20), new Arma("alcachofa", 5), new Arma("aguacate", 10)
            }));
            gwen    = new Spider_Gwen(10, new Traje(30, null), 10);
            miles   = new Miles_Morales(20, new Traje(60, null), 15);
            kingpin = new Kingpin();

            equipo = new SpiderTeam(new List <Spiderman>()
            {
                peter, noir, gwen, miles
            });
        }
예제 #7
0
        static void Main(string[] args)
        {
            var debug   = Kingpin.Flag("debug", "Enable debug mode.").IsBool();
            var timeout = Kingpin.Flag("timeout", "Timeout waiting for ping.").IsRequired().Short('t').IsDuration();
            var ip      = Kingpin.Argument("ip", "IP address to ping.").IsRequired().IsIp();
            var count   = Kingpin.Argument("count", "Number of packets to send").IsInt();

            Kingpin
            .Version("0.0.1")
            .Author("Joe Malone")
            .ExitOnHelp()
            .ShowHelpOnParsingErrors()
            .Parse(args);

            Console.WriteLine($"Would ping: {ip} with timeout {timeout} and count {count} with debug set to {debug}");
            Console.ReadLine();
        }
예제 #8
0
        static void Main(string[] args)
        {
            Kingpin.ShowHelpOnParsingErrors();
            // Kingpin.ExitOnParsingErrors();
            Kingpin.Flag("registry", "The registry to pull data from");
            Kingpin.Flag("registrys", "The registrys to pull data from");
            Kingpin.Flag("connectionstring", "Database connection string");
            Kingpin.Flag("database", "The name of the database to write data to");
            Kingpin.Flag("token", "The API token to use to connect to checquehistoricaldata.com");

            var schemaCmd = Kingpin.Command("schema", "Database schema commands");

            schemaCmd.Command("create", "Create the schema on the database");

            var basedataCmd = Kingpin.Command("basedata", "Metadata commands");

            basedataCmd.Command("get", "Get basedata for registry(s)");

            var quoteCmd    = Kingpin.Command("checque", "checque data commands");
            var quoteGetCmd = quoteCmd.Command("get", "Get checque data for registry(s)");

            quoteGetCmd.Flag("from", "From date").IsDate();
            quoteGetCmd.Flag("to", "From date").IsDate();

            var normalizeCmd = Kingpin.Command("normalize", "Normalize checque data");

            normalizeCmd.Flag("symbol", "The symbol to normalize");
            normalizeCmd.Flag("force", "Force generation of normalized data from start of time").IsBool().Short('f');
            normalizeCmd.Flag("all", "Force generation of normalized data for all checque in the registry").IsBool().Short('a');

            var calculateCmd = Kingpin.Command("calculate", "Calculate factors");
            var betasCmd     = calculateCmd.Command("betas", "Calculate beta factors");

            betasCmd.Flag("symbol", "Symbol to run calculations on");
            betasCmd.Flag("force", "Force calculation from start of time").IsBool().Short('f');
            betasCmd.Flag("all", "Force generation of beta factors for all checque in the registry").IsBool().Short('a');

            var rankCmd = calculateCmd.Command("rank", "Rank checque against each other in the same registry");

            rankCmd.Flag("force", "Force calculation from start of time").IsBool().Short('f');
            rankCmd.Flag("date", "Calculate for date").IsDate();

            var result = Kingpin.Parse(args);

            Console.ReadLine();
        }
예제 #9
0
        static void Main(string[] args)
        {
            var runCommand  = Kingpin.Command("run", "run a command").IsDefault();
            var generalFlag = Kingpin.Flag("general", "a general flag").Short('g').IsInt().IsUrl().IsIp().IsEnum(typeof(EnumType)).IsDuration().IsTcp().IsFloat().Default("5s");

            var runUrlCommand = runCommand.Command("url", "Run a URL");

            var runUrlArgument = runUrlCommand.Argument("url", "the url to run").IsRequired().IsUrl().FileExists().DirectoryExists();
            var runUrlFlag     = runUrlCommand.Flag("flag", "a flag").Short('f').IsInt().IsUrl().IsIp().IsEnum(typeof(EnumType)).IsDuration().IsTcp().IsFloat().Default("5s");
            var runUrlSwitch   = runUrlCommand.Flag("switch", "a switch").IsBool();

            var configuration = new ConfigurationBuilder().AddEnvironmentVariables().AddKingpinNetCommandLine(args).Build();

            if (configuration["help"] == "true")
            {
                return;
            }
            Console.WriteLine(configuration["flag"]);
            Console.ReadLine();
        }
예제 #10
0
        static void Main(string[] args)
        {
            Kingpin.ExitOnHelp();
            Kingpin.ExitOnParsingErrors();
            Kingpin.ShowHelpOnParsingErrors();
            Kingpin.ExitOnNoArguments();
            Kingpin.ShowHelpOnNoArguments();
            Kingpin.Category("Motif", "Easy generation of entire projects and solutions using Liquid syntax");
            Kingpin.Author("Peter Andersen");
            Kingpin.Version(Assembly.GetEntryAssembly()?.GetName().Version?.ToString());
            Kingpin.Command("create", "Create directories and files based on the definition file");
            Kingpin.Command("update", "Update directories and files based on the definition file");
            Kingpin.Flag("definition", "Motif YAML definition file").Short('d').IsRequired();
            Kingpin.Flag("output", "Output folder for generated directories and files").Short('o').IsRequired();
            Kingpin.Flag("template", "Motif template folder").DirectoryExists().Short('t').IsRequired();

            var configuration = new ConfigurationBuilder().AddKingpinNetCommandLine(args).Build();

            // Kingpin.Parse(args);
            Console.ReadLine();
        }
예제 #11
0
        public void Setup()
        {
            laser    = new Arma(10, "Acme");
            telaraña = new Arma(20, "Casero");

            TsiderNoir = new Traje(40, new List <Arma> {
                laser, telaraña
            });
            Tspidermans = new Traje(68, new List <Arma> {
                telaraña
            });

            gwen         = new SpiderGwen(6, 20, Tspidermans);
            milesMorales = new MilesMorales(20, 40, Tspidermans);
            spiderman    = new PeterParker(30, Tspidermans);
            noir         = new SpidermanNoir(24, TsiderNoir);

            kingpin = new Kingpin();

            spiderTeam = new SpiderTeam(new List <Spiderman> {
                gwen, milesMorales, spiderman, noir
            });
        }
예제 #12
0
 public void Atacar(Kingpin kinpin)
 {
     kinpin.sacarleVida(poder);
 }
 public void atacar(Kingpin kingpin) => kingpin.reducirVida(poder());
 public void Atacar(Kingpin kpin)
 {
     kpin.EsAtacado(this.Poder());
 }