예제 #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();
        }
예제 #2
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");
            }
        }
예제 #3
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();
        }
예제 #4
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();
        }
예제 #5
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();
        }