示例#1
0
        static int Main(string[] args)
        {
            var parser    = new CommandLineParser.CommandLineParser(); //switch argument is meant for true/false logic
            var inputFile = new FileArgument('i', "input", "Input Excellon file")
            {
                FileMustExist = true, Optional = false
            };
            var inputRealFile = new FileArgument('i', "input", "Input file with 2 imaginary and real points")
            {
                FileMustExist = true, Optional = false
            };
            var outputFile = new FileArgument('o', "output", "Output Excellon file with all real coordinates")
            {
                FileMustExist = false, Optional = false
            };

            parser.Arguments.Add(inputFile);
            parser.Arguments.Add(outputFile);
            try
            {
                parser.ParseCommandLine(args);
                using (var reader = inputFile.Value.OpenText())
                    using (var writer = new StreamWriter(outputFile.Value.OpenWrite()))
                    {
                    }

                return(0);
            }
            catch (CommandLineException e)
            {
                Console.WriteLine(e.Message);
                return(-1);
            }
        }
示例#2
0
        static void ParseCommandLine(string[] args, out CommandLineParser.Arguments.FileArgument config, out CommandLineParser.Arguments.SwitchArgument debug, out CommandLineParser.Arguments.SwitchArgument fetch, out CommandLineParser.Arguments.SwitchArgument summary)
        {
            config = new CommandLineParser.Arguments.FileArgument('c', "config")
            {
                ForcedDefaultValue = new FileInfo("config.json")
            };

            debug = new CommandLineParser.Arguments.SwitchArgument('d', "debug", false);

            fetch = new CommandLineParser.Arguments.SwitchArgument('f', "fetch", false);

            summary = new CommandLineParser.Arguments.SwitchArgument('s', "summary", false);

            var commandLineParser = new CommandLineParser.CommandLineParser()
            {
                Arguments =
                {
                    config,
                    debug,
                    fetch,
                    summary,
                }
            };

            commandLineParser.ParseCommandLine(args);
        }
示例#3
0
        private static async Task RunApplication(string[] args)
        {
            var toolArguments = new ToolArguments();

            var cmdLineParser = new CommandLineParser.CommandLineParser
            {
                ShowUsageHeader = "Here is how you use the repository provisioning app:",
                ShowUsageFooter = "For more information, see https://github.com/arcus-azure/arcus"
            };

            try
            {
                cmdLineParser.ExtractArgumentAttributes(toolArguments);
                cmdLineParser.ParseCommandLine(args);

                await ConfigureRepositoryDefaults(toolArguments);
            }
            catch (MandatoryArgumentNotSetException)
            {
                Console.ForegroundColor = AnnouncementColor;
                Console.WriteLine(value: "Failed to interpret your request. Here are the parsed commands.");
                cmdLineParser.ShowParsedArguments();

                Console.WriteLine(value: "Please make sure that you call the commands correctly.\r\n");
                ShowUsage(cmdLineParser);
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            // PARSE ARGS
            var argsParser = new CommandLineParser.CommandLineParser();
            var parsedArgs = new ConsoleArgs();

            argsParser.ExtractArgumentAttributes(parsedArgs);
            argsParser.ParseCommandLine(args);

            if (parsedArgs.Help)
            {
                argsParser.ShowUsage();
                Environment.Exit(-1);
            }

            var appRunTimer = new Stopwatch();

            appRunTimer.Start();

            var runner = new Runner();

            runner.Run(parsedArgs);

            appRunTimer.Stop();

            if (parsedArgs.NoExit)
            {
                System.Console.ReadKey();
            }
        }
示例#5
0
        static void Main(string[] args)
        {
            var arg = new FileArgument('i', "inputFile")
            {
                FileMustExist = true
            };
            var parser = new CommandLineParser.CommandLineParser
            {
                AcceptEqualSignSyntaxForValueArguments = true,
                AcceptHyphen = true,
                AcceptSlash  = true
            };

            parser.Arguments.Add(arg);

            try
            {
                parser.ParseCommandLine(args);
                if (!arg.Parsed)
                {
                    throw new NotSupportedException("No argument provided.");
                }

                var icons = Collect(arg.Value.FullName).ToList();
                Generate(icons);
            }
            catch (Exception e)
            {
                Console.WriteLine("The process was aborted mid-way. Some icons may have been generated.");
                Console.WriteLine(e.Message);
                return;
            }
            Console.WriteLine("All done!");
        }
示例#6
0
        static void Main(string[] args)
        {
            // Setup parser and extract command line arguments
            var parser      = new CommandLineParser.CommandLineParser();
            var cmdLineArgs = new CommandLineArgs();

            try
            {
                // Add the verbose switch programmatically because I am having issues with the attributes
                var verbose = new SwitchArgument('v', "verbose", "Turns on verbose output.", false);
                parser.Arguments.Add(verbose);

                parser.ShowUsageHeader = "Downloads a file or folder from VSTS to the specified location.\r\n\r\n" +
                                         "VSTS-GET -a <Account> [-u <User ID>] -p <Password> -t <Project> -r <Repo> [-f|-o] <File/Folder> " +
                                         "-d <Destination>";
                parser.ShowUsageOnEmptyCommandline = true;

                parser.ExtractArgumentAttributes(cmdLineArgs);
                parser.ParseCommandLine(args);

                if (parser.ParsingSucceeded)
                {
                    var authentication = new BasicAuthentication(cmdLineArgs.Account, cmdLineArgs.UserId, cmdLineArgs.Password);

                    if (!string.IsNullOrEmpty(cmdLineArgs.FilePath))
                    {
                        // If the --file argument was specified, then assume we're downloading a single file
                        var helper = new VstsHelper();

                        Console.WriteLine(helper.DownloadFile(authentication, cmdLineArgs.Project, cmdLineArgs.Repo,
                                                              cmdLineArgs.FilePath, cmdLineArgs.Destination,
                                                              verbose.Value)
                            ? "    File download successful."
                            : "    File download failed.");
                    }
                    else if (!string.IsNullOrEmpty(cmdLineArgs.FolderPath))
                    {
                        var helper = new VstsHelper();

                        Console.WriteLine(helper.DownloadFolder(authentication, cmdLineArgs.Project, cmdLineArgs.Repo,
                                                                cmdLineArgs.FolderPath, cmdLineArgs.Destination,
                                                                verbose.Value)
                            ? "    Folder download successful."
                            : "    Folder download failed.");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                parser.ShowUsage();
            }

            if (Debugger.IsAttached)
            {
                // Keep the console window from closing when running from IDE
                Console.WriteLine("\r\nPress any key to close command window.");
                Console.ReadKey();
            }
        }
示例#7
0
        /// <summary>
        /// Processes the command line.
        /// </summary>
        /// <param name="args">Command line arguments</param>
        private void ProcessCommandLine(string[] args)
        {
            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();
            parser.ShowUsageOnEmptyCommandline = false;
            parser.ExtractArgumentAttributes(this);
            parser.FillDescFromResource((CommandLineParser.IResource) new CommandlineArguments());

#if testingconsole
            args = new string[]
            {
                "--project",
                @"D:\Programování\XCase\Test\ABCCompany.XCase",
                //"--outputDir",
                //@"D:\Programování\XCase\Test\cmdoutput\",
                //"-d",
                //"0;1",
                // "-d",
                //"2(filename2)",
                //"-d",
                //"TransportDetailFormat(filename5)[I]"
                //"1-3(filename1,filename2,filename3)[I]"
                //"3"
            };
            //args = new string[] {"-i", "asdf"};
#endif
            try
            {
                parser.ParseCommandLine(args);
            }
            catch (CommandLineParser.Exceptions.CommandLineException e)
            {
                Console.WriteLine("Error in command line parameters: ");
                Console.WriteLine(e.Message);
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Correct usage: ");
                parser.ShowUsage();
                ShutDown();
                return;
            }

            #region List and Help

            if (Help)
            {
                HelpAndShutdown(parser);
                return;
            }

            // povolena kombinace list + project
            if (List)
            {
                ListAndShutdown();
                return;
            }

            #endregion

            Export();
        }
示例#8
0
        private static void Main(string[] args)
        {
            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser
            {
                IgnoreCase = true,
                ShowUsageOnEmptyCommandline = true
            };

            argv = new CommandLineArguments();

            parser.ExtractArgumentAttributes(argv);

            try
            {
                parser.ParseCommandLine(args);
            }
            catch (Exception e)
            {
                Console.WriteLine($"[FATAL] {e.Message}");
            }

            if (parser.ParsingSucceeded)
            {
                CommandLineActions.Run(argv);
            }
        }
示例#9
0
        public static CommandLineParser.CommandLineParser Get()
        {
            try
            {
                var parser = new CommandLineParser.CommandLineParser();

                ValueArgument <string> project = new ValueArgument <string>(
                    'p', "project", "Specify the project path file");
                project.Optional = false;

                ValueArgument <string> github = new ValueArgument <string>(
                    'g', "github", "Specify the username/repository of github");
                github.Optional = false;

                SwitchArgument force = new SwitchArgument('f', "force", "Force recreate file", false);

                parser.Arguments.Add(project);
                parser.Arguments.Add(force);
                parser.Arguments.Add(github);

                return(parser);
            }
            catch (CommandLineArgumentException ex)
            {
                if (args.Count() > 0)
                {
                    Console.WriteLine(ex.Message);
                }
                parser.ShowUsage();
            }
        }
示例#10
0
        private static void ParseCommandLineArgs(string[] args)
        {
            var parser = new CommandLineParser.CommandLineParser
            {
                ShowUsageOnEmptyCommandline = true,
                AcceptSlash = true
            };

            //var silentModeArgument = new SwitchArgument(
            //        's',
            //        "silent",
            //        "Executes AutoDEMO in silent mode",
            //        false)
            //    { Optional = true };
            //parser.Arguments.Add(silentModeArgument);

            try
            {
                parser.ParseCommandLine(args);

                //Options.SilentMode = silentModeArgument.Value;
            }
            catch (CommandLineException cle)
            {
                Debug.WriteLine($"CommandLineException: {cle.Message}");
            }
        }
示例#11
0
        private static void Main(string[] args)
        {
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator    = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser
            {
                IgnoreCase = true,
                ShowUsageOnEmptyCommandline = true
            };

            argv = new CommandLineArguments();

            parser.ExtractArgumentAttributes(argv);

#if !DEBUG
            try
            {
#endif
            parser.ParseCommandLine(args);
#if !DEBUG
        }
        catch (Exception e)
        {
            Console.WriteLine($"[FATAL] {e.Message}");
        }
#endif

            if (parser.ParsingSucceeded)
            {
                CommandLineActions.Run(argv);
            }
        }
示例#12
0
        /// <summary>
        /// Main entry point
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            ILogger logger = new ConsoleLogger();

            try
            {
                var parser = new CommandLineParser.CommandLineParser {
                    ShowUsageOnEmptyCommandline = true
                };
                var appArgs = new ApplicationArguments();
                parser.ExtractArgumentAttributes(appArgs);
                parser.ParseCommandLine(args);
                parser.Dispose();

                if (args.Length > 0 && !HelpWanted(args))
                {
                    var processor = new ApplicationArgumentProcessor
                    {
                        Logger            = logger,
                        ProgressIndicator = new ConsoleProgressIndicator()
                    };
                    processor.Process(appArgs);
                }
            }
            catch (Exception e)
            {
                logger.Log(e.Message);
            }
        }
示例#13
0
        public static void Main(string [] args)
        {
            var parser    = new CommandLineParser.CommandLineParser();
            var algorithm = new EnumeratedValueArgument <string> (
                'a',
                "algorithm",
                "available algorithms for computing hash, default to SHA1",
                new [] { Md2Hash.ALGORITHM_NAME,
                         Md5Hash.ALGORITHM_NAME,
                         Sha1Hash.ALGORITHM_NAME,
                         Sha256Hash.ALGORITHM_NAME,
                         Sha384Hash.ALGORITHM_NAME,
                         Sha512Hash.ALGORITHM_NAME });

            algorithm.DefaultValue = Sha1Hash.ALGORITHM_NAME;
            var source = new ValueArgument <string> (
                's',
                "source",
                "source to compute hash");

            source.Optional = false;
            var salt = new ValueArgument <string> (
                't',
                "salt",
                "salt for computing hash");
            var iterations = new ValueArgument <int> (
                'i',
                "iterations",
                "iterations when compute hash");

            iterations.DefaultValue = 1;
            parser.Arguments.AddRange(
                new Argument [] { algorithm, source, salt, iterations });

            parser.ParseCommandLine(args);

            if (!source.Parsed || string.IsNullOrEmpty(source.Value))
            {
                parser.ShowUsage();
                return;
            }

            SimpleHash hash = null;

            if (algorithm.Parsed)
            {
                hash = new SimpleHash(algorithm.Value, source.Value, salt.Value, iterations.Value);
            }
            if (hash == null)
            {
                hash = new Sha1Hash(source.Value, salt.Value, iterations.Value);
            }

            Console.WriteLine("algorithms  :" + hash.AlgorithmName);
            Console.WriteLine("source      :" + source.Value);
            Console.WriteLine("salt        :" + salt.Value);
            Console.WriteLine("iterations  :" + iterations.Value);
            Console.WriteLine("hash(hex)   :" + hash.ToHex());
            Console.WriteLine("hash(base64):" + hash.ToBase64());
        }
示例#14
0
        private static CommandLineOptions ProcessComandLineParameters(string[] args)
        {
            var options           = new CommandLineOptions();
            var commandLineParser = new CommandLineParser.CommandLineParser
            {
                ShowUsageOnEmptyCommandline = true,
                AcceptSlash = true,
                IgnoreCase  = true,
            };

            commandLineParser.ExtractArgumentAttributes(options);
            if (!args.Any() || args.Any(c => showUsageCommands.Contains(c)))
            {
                LocalizationManager.Instance.AssignCurrentCulture();
                commandLineParser.FillDescFromResource(new CmdResources());
            }

            try
            {
                commandLineParser.ParseCommandLine(args);
            }
            catch (CommandLineException)
            {
                throw new CommandLineException("Incorrect command line parameters");
            }

            return(options);
        }
示例#15
0
        static void Main(string[] args)
        {
            var config = new CommandLineParser.Arguments.FileArgument('c', "config")
            {
                ForcedDefaultValue = new FileInfo("config.json")
            };

            var commandLineParser = new CommandLineParser.CommandLineParser()
            {
                Arguments =
                {
                    config,
                }
            };

            try
            {
                commandLineParser.ParseCommandLine(args);

                AsyncMain(new ConfigurationBuilder()
                          .AddJsonFile(config.Value.FullName, true)
                          .Build()).Wait();
            }
            catch (CommandLineParser.Exceptions.CommandLineException e)
            {
                Console.WriteLine(e.Message);
            }
        }
示例#16
0
        static void Main(string[] args)
        {
            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();
            ValueArgument <string> path = new ValueArgument <string>('p', "path", "Folder with the contents");

            parser.Arguments.Add(path);
            try
            {
                parser.ParseCommandLine(args);
                var extractedFolder = string.Empty;
                if (path.Parsed)
                {
                    extractedFolder = path.Value;
                }
                if (String.IsNullOrWhiteSpace(extractedFolder))
                {
                    parser.ShowUsage();
                }
                var worker = new Worker("correspondences.json");
                worker.Work(extractedFolder);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#17
0
        public static void Main(string[] args)
        {
            try {
                var parser  = new CommandLineParser.CommandLineParser();
                var options = new ParsingTarget();
                parser.ExtractArgumentAttributes(options);
                parser.ParseCommandLine(args);

                IExample example;
                switch (options.Type)
                {
                case "producer":
                    example = new Producer();
                    break;

                case "consumer":
                    example = new SimpleConsumer();
                    break;

                case "group":
                    example = new GroupConsumer();
                    break;

                default:
                    throw new NotImplementedException($"unknown example {options.Type}");
                }

                Nito.AsyncEx.AsyncContext.Run(async() => await example.RunAsync(new KafkaOptions(new Uri(options.Server)), options.Topic));
            } catch (CommandLineException e) {
                Console.WriteLine(e.Message);
            }
        }
示例#18
0
        static async Task Main(string[] args)
        {
            var parser  = new CommandLineParser.CommandLineParser();
            var options = new ParsingOptions();

            try
            {
                parser.ExtractArgumentAttributes(options);
                parser.ParseCommandLine(args);
            }
            catch (CommandLineException e)
            {
                Console.WriteLine(e.Message);

                /*
                 * you can help the user by printing all the possible arguments and their
                 * description, CommandLineParser class can do this for you.
                 */
                parser.ShowUsage();
                return;
            }

            await Trainer.TrainAsync(options);

#if DEBUG
            Console.ReadLine();
#endif
        }
        static void Main(string[] args)
        {
            CommandLineParser.CommandLineParser parser = CreateParser();

            try
            {
                parser.ParseCommandLine(args);
            }
            catch (CommandLineException e)
            {
                Console.WriteLine(e.Message);
                parser.ShowUsage();
                return;
            }


            String connectionString = ((ValueArgument <SqlConnectionStringBuilder>)parser.LookupArgument("connectionString")).Value.ConnectionString;
            String inputFileName    = ((FileArgument)parser.LookupArgument("input")).Value.FullName;
            String outputFileName   = ((FileArgument)parser.LookupArgument("output")).Value != null ?
                                      ((FileArgument)parser.LookupArgument("output")).Value.FullName :
                                      inputFileName;

            Program p = new Program(connectionString, inputFileName, outputFileName);

            p.CreateDocumentation();
            p.Dispose();
        }
示例#20
0
        private static void ProcessFile(H3ToGeoBoundaryArguments argParser, CommandLineParser.CommandLineParser parser)
        {
            if (!File.Exists(argParser.InputFileName))
            {
                Console.WriteLine($"Unable to open {argParser.InputFileName}");
                parser.ShowUsage();
                return;
            }

            try
            {
                var lines = File.ReadLines(argParser.InputFileName);
                foreach (string line in lines)
                {
                    bool test = ulong.TryParse(line.Trim(), out ulong value);
                    if (!test)
                    {
                        continue;
                    }
                    var h3 = new H3Index(value);
                    Console.Write(DoCell(h3, argParser));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
示例#21
0
文件: Program.cs 项目: qljiong/KSOA
        private static CommandLineParser.CommandLineParser CreateParser()
        {
            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();
            ValueArgument<SqlConnectionStringBuilder> connectionStringArgument = new ValueArgument<SqlConnectionStringBuilder>('c', "connectionString", "ConnectionString of the documented database")
            {
                Optional = false,
                ConvertValueHandler = (stringValue) =>
                {
                    SqlConnectionStringBuilder connectionStringBuilder;
                    try
                    {
                        connectionStringBuilder = new SqlConnectionStringBuilder(stringValue);
                    }
                    catch
                    {
                        throw new InvalidConversionException("invalid connection string", "connectionString");
                    }
                    if (String.IsNullOrEmpty(connectionStringBuilder.InitialCatalog))
                    {
                        throw new InvalidConversionException("no InitialCatalog was specified", "connectionString");
                    }

                    return connectionStringBuilder;
                }
            };
            FileArgument inputFileArgument = new FileArgument('i', "input", "original edmx file") { FileMustExist = true, Optional = false };
            FileArgument outputFileArgument = new FileArgument('o', "output", "output edmx file - Default : original edmx file") { FileMustExist = false, Optional = true };

            parser.Arguments.Add(connectionStringArgument);
            parser.Arguments.Add(inputFileArgument);
            parser.Arguments.Add(outputFileArgument);

            parser.IgnoreCase = true;
            return parser;
        }
示例#22
0
        private CommandLineParser.CommandLineParser InitIgnoreCase()
        {
            var commandLineParser = new CommandLineParser.CommandLineParser();

            commandLineParser.IgnoreCase = true;
            commandLineParser.ShowUsageOnEmptyCommandline = true;

            SwitchArgument showArgument = new SwitchArgument('s', "show", "Set whether show or not", true);

            SwitchArgument hideArgument = new SwitchArgument('h', "hide", "Set whether hid or not", false);

            ValueArgument <string> level = new ValueArgument <string>('l', "level", "Set the level");

            ValueArgument <decimal> version = new ValueArgument <decimal>('v', "version", "Set desired version");

            ValueArgument <Point> point = new ValueArgument <Point>('p', "point", "specify the point");

            BoundedValueArgument <int> optimization = new BoundedValueArgument <int>('o', "optimization", 0, 3);

            EnumeratedValueArgument <string> color = new EnumeratedValueArgument <string>('c', "color", new[] { "red", "green", "blue" });

            FileArgument inputFile = new FileArgument('i', "input", "Input file");

            inputFile.FileMustExist = false;
            FileArgument outputFile = new FileArgument('x', "output", "Output file");

            outputFile.FileMustExist = false;

            DirectoryArgument inputDirectory = new DirectoryArgument('d', "directory", "Input directory");

            inputDirectory.DirectoryMustExist = false;

            point.ConvertValueHandler = delegate(string stringValue)
            {
                if (stringValue.StartsWith("[") && stringValue.EndsWith("]"))
                {
                    string[] parts =
                        stringValue.Substring(1, stringValue.Length - 2).Split(';', ',');
                    Point p = new Point();
                    p.x = int.Parse(parts[0]);
                    p.y = int.Parse(parts[1]);
                    return(p);
                }

                throw new CommandLineArgumentException("Bad point format", "point");
            };

            commandLineParser.Arguments.Add(showArgument);
            commandLineParser.Arguments.Add(hideArgument);
            commandLineParser.Arguments.Add(level);
            commandLineParser.Arguments.Add(version);
            commandLineParser.Arguments.Add(point);
            commandLineParser.Arguments.Add(optimization);
            commandLineParser.Arguments.Add(color);
            commandLineParser.Arguments.Add(inputFile);
            commandLineParser.Arguments.Add(outputFile);
            commandLineParser.Arguments.Add(inputDirectory);

            return(commandLineParser);
        }
        /// <summary>
        /// Entry point of the CLI.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        private static void Main(string[] args)
        {
            var cliParser         = new CommandLineParser.CommandLineParser();
            var directoryArgument = new DirectoryArgument('d', "directory", "The directory containing the files to match.")
            {
                DirectoryMustExist = true, Optional = true, DefaultValue = new DirectoryInfo(Environment.CurrentDirectory)
            };
            var fileExtensionArgument = new ValueArgument <string>('x', "extension", "The file extension (without dot) to match as a regular expression pattern, e.g. \"^(pdf|jpe?g)$\" or \"db$\". Matches all extensions if omitted.")
            {
                Optional = true, DefaultValue = string.Empty
            };
            var startDateArgument = new ValueArgument <DateTime>('s', "start-date", "The range start date (YYYY-MM-DD).")
            {
                Optional = false
            };
            var endDateArgument = new ValueArgument <DateTime>('e', "end-date", "The range end date (YYYY-MM-DD).")
            {
                Optional = false
            };

            cliParser.ShowUsageHeader = "Check if a directory containing files with named date ranges is missing any dates from a given range.";
            cliParser.Arguments.Add(directoryArgument);
            cliParser.Arguments.Add(fileExtensionArgument);
            cliParser.Arguments.Add(startDateArgument);
            cliParser.Arguments.Add(endDateArgument);
            cliParser.ShowUsageOnEmptyCommandline = true;

            try
            {
                cliParser.ParseCommandLine(args);
            }
            catch (CommandLineException cle)
            {
                Console.WriteLine(cle.Message);
                cliParser.ShowUsage();
                return;
            }
            catch (DirectoryNotFoundException dnfe)
            {
                Console.WriteLine(dnfe.Message.EndsWith(" and DirectoryMustExist flag is set to true.")
                    ? dnfe.Message.Substring(0, dnfe.Message.Length - 44)
                    : dnfe.Message);
                return;
            }

            if (!cliParser.ParsingSucceeded)
            {
                return;
            }

            if (startDateArgument.Value > endDateArgument.Value)
            {
                Console.WriteLine("The start date of the range cannot be later than the end date.");
                return;
            }

            Console.BackgroundColor = ConsoleColor.Black;

            if (HasMissingRanges(directoryArgument.Value, fileExtensionArgument.Value, (startDateArgument.Value, endDateArgument.Value), out (DateTime, DateTime)[] missingRanges))
示例#24
0
        public static int  Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            var commandLineParser = new CommandLineParser.CommandLineParser();

            var sourcePath = new FileArgument('i', "input", "Source file path")
            {
                Optional = false
            };
            var outPath = new FileArgument('o', "output", "Output file path")
            {
                Optional = true, FileMustExist = false
            };

            var lexicalAnalysis = new SwitchArgument('l', "lexical", false);
            var syntaxAnalysis  = new SwitchArgument('s', "syntax", false);
            var semanticsCheck  = new SwitchArgument('c', "semantics", "turn off semantics check", true);
            var codeGeneration  = new SwitchArgument('a', "assembler", "generate assembler", false);
            var optimization    = new SwitchArgument('O', "optimization", "optimization", false);

            commandLineParser.Arguments.Add(sourcePath);
            commandLineParser.Arguments.Add(outPath);
            commandLineParser.Arguments.Add(lexicalAnalysis);
            commandLineParser.Arguments.Add(syntaxAnalysis);
            commandLineParser.Arguments.Add(semanticsCheck);
            commandLineParser.Arguments.Add(codeGeneration);
            commandLineParser.Arguments.Add(optimization);

            var compileStageGroupCertification = new ArgumentGroupCertification("l,s,a", EArgumentGroupCondition.ExactlyOneUsed);

            commandLineParser.Certifications.Add(compileStageGroupCertification);

            try {
                commandLineParser.ParseCommandLine(args);
            }
            catch (CommandLineException) {
                commandLineParser.ShowUsage();
                return(1);
            }
            using (var output = outPath.Value == null ? Console.Out : new StreamWriter(outPath.StringValue))
                using (var input = new StreamReader(sourcePath.OpenFileRead())) {
                    if (lexicalAnalysis.Value)
                    {
                        PerformLexicalAnalysis(input, output);
                    }

                    if (syntaxAnalysis.Value)
                    {
                        PerformSyntaxAnalysis(input, output, semanticsCheck.Value);
                    }

                    if (codeGeneration.Value)
                    {
                        PerformCodeGeneration(input, output, optimization.Value);
                    }
                }

            return(0);
        }
        public CommandLineParser.CommandLineParser InitValueArgument()
        {
            var commandLineParser = new CommandLineParser.CommandLineParser();

            valueArgumentTarget = new ValueArgumentParsingTarget();
            commandLineParser.ExtractArgumentAttributes(valueArgumentTarget);
            return(commandLineParser);
        }
示例#26
0
        private static CommandLineParser.CommandLineParser CreateParser()
        {
            var parser = new CommandLineParser.CommandLineParser { IgnoreCase = true };

            parser.Arguments.Add(new FileArgument('i', "input", "original edmx file") { FileMustExist = true, Optional = false });

            return parser;
        }
示例#27
0
        private static void Main(string[] args)
        {
            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();

            ValueArgument <string> inputLogFile = new ValueArgument <string>('i', "input", "Specify filepath of CSV file to process");

            inputLogFile.Optional = false;
            ValueArgument <string> outputLogFile = new ValueArgument <string>('o', "output", "Specify filepath to save CSV file");

            outputLogFile.Optional = false;
            ValueArgument <string> connectionString = new ValueArgument <string>('c', "connection", "Specify connection string");

            connectionString.Optional = false;

            parser.Arguments.Add(inputLogFile);
            parser.Arguments.Add(outputLogFile);
            parser.Arguments.Add(connectionString);

            //parser.ShowUsageHeader = "Welcome to EventParser!";
            //parser.ShowUsageFooter = "Thank you for using the application.";
            //parser.ShowUsage();

            try
            {
                parser.ParseCommandLine(args);
                if (inputLogFile.Parsed)
                {
                    Arguments.input = inputLogFile.Value;
                }
                if (outputLogFile.Parsed)
                {
                    Arguments.output = outputLogFile.Value;
                }
                if (connectionString.Parsed)
                {
                    Arguments.connString = connectionString.Value;
                }
            }
            catch (CommandLineException e)
            {
                Console.WriteLine(e.Message);
                parser.ShowUsage();
            }

            // Validation
            if (Arguments.input != null && Arguments.output != null && Arguments.connString != null)
            {
                Console.WriteLine($"PROCESSING: {Arguments.input}");
                Stopwatch sw = Stopwatch.StartNew();

                AddMissingHeader();
                ParseLog();
                ImportToMSSQL();

                Console.WriteLine("Success.");
                Console.WriteLine($"Time elapsed: {sw.ElapsedMilliseconds} ms");
            }
        }
示例#28
0
        public static void Main(string[] args)
        {
            const string configFilePath = @"../../../config/config.yaml";
            var          config         = configFilePath.GetIoTConfiguration();
            var          testDevices    = config.DeviceConfigs;
            var          azureConfig    = config.AzureIoTHubConfig;

            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();
            var commandLineArguments = new CommandLineArguments();

            parser.ExtractArgumentAttributes(commandLineArguments);
            parser.ParseCommandLine(args);

            _registryManager = RegistryManager.CreateFromConnectionString(azureConfig.ConnectionString);

            if (commandLineArguments.NumberOfDeviceToCreate > 0)
            {
                var deviceNamePrefix = commandLineArguments.DeviceNamePrefix;
                testDevices = config.DeviceConfigs = new System.Collections.Generic.List <DeviceConfig>();
                for (int deviceNumber = 0; deviceNumber < commandLineArguments.NumberOfDeviceToCreate; deviceNumber++)
                {
                    var testDevice = new DeviceConfig()
                    {
                        DeviceId = $"{deviceNamePrefix}{deviceNumber:0000}",
                        Nickname = $"{deviceNamePrefix}{deviceNumber:0000}",
                        Status   = "Enabled"
                    };
                    testDevices.Add(testDevice);

                    var task = AddDeviceAsync(testDevice);
                    task.Wait();

                    testDevice.Key = task.Result;
                }
            }
            else
            {
                foreach (var testDevice in testDevices)
                {
                    var task = AddDeviceAsync(testDevice);
                    task.Wait();

                    testDevice.Key = task.Result;
                }
            }

            if (configFilePath.UpdateIoTConfiguration(config).Item1)
            {
                foreach (var testDevice in testDevices)
                {
                    Console.WriteLine(
                        $"DeviceId: {testDevice.DeviceId} has DeviceKey: {testDevice.Key} \r\nConfig file: {configFilePath} has been updated accordingly.");
                }
            }


            Console.ReadLine();
        }
示例#29
0
        /// <summary>
        ///     Acciones a realizar con los parámetros.
        ///     Verifica si los parámetros introducidos están dentro
        ///     de rango, de lo contrario asigna valores por defecto
        ///     o muestra mensajes de error.
        /// </summary>
        /// <param name="parser">
        ///     Analiza los parámetros pasados por línea de comandos.
        /// </param>
        /// <param name="param">
        ///     Parámetros pasados por línea de comandos.
        /// </param>
        public void SeleccionParametros(CommandLineParser.CommandLineParser parser, Parametros param)
        {
            var consola = new Consola();

            // Ayuda
            if (param.Help)
            {
                MostrarAyudaParametros(parser, param);
            }

            // Version
            if (param.Version)
            {
                consola.MsgVersion();
            }

            // Listado de puertos
            if (param.ListCom)
            {
                consola.MsgListadoPuertos();
            }

            // Flujo de configuración manual
            if (ParamPort == null || param.Help || param.ListCom || param.Version)
            {
                return;
            }

            // Puerto
            ValidaParamPort(param.Port, _patrones);
            Console.WriteLine($"{consola.Prompt}Puerto: {ParamPort}");

            // Velocidad
            ValidaParamSpeed(param.Speed);
            Console.WriteLine($"{consola.Prompt}Velocidad: {ParamSpeed}");

            // Paridad
            ValidaParidad(param.Parity);
            Console.WriteLine($"{consola.Prompt}Bit de paridad: {ParamParity}");

            // Bits de datos
            ValidaDataBits(param.DataBits);
            Console.WriteLine($"{consola.Prompt}Bits de comunicaciones: {ParamDataBits}");

            // Bits de parada
            ValidaStopBits(param.StopBits);
            Console.WriteLine($"{consola.Prompt}Asignado bit de parada: {ParamStopBits}");

            // >>> CONEXIÓN <<<
            var conexionSerie = new SerialCom(ParamPort, ParamSpeed, ParamParity, ParamDataBits, ParamStopBits);

            if (param.Info && conexionSerie.ComOk)
            {
                consola.MostrarParametros(conexionSerie);
            }

            conexionSerie.Conectar();
        }
示例#30
0
        public static CILantroArgs Parse(string[] args)
        {
            var result = new CILantroArgs();
            var parser = new CommandLineParser.CommandLineParser();

            parser.ExtractArgumentAttributes(result);
            parser.ParseCommandLine(args);
            return(result);
        }
示例#31
0
        public CommandLineParser.CommandLineParser InitForCertifiedValueArgument()
        {
            var commandLineParser = new CommandLineParser.CommandLineParser();

            target = new CertifiedValueArgumentParsingTarget();
            commandLineParser.ExtractArgumentAttributes(target);

            return(commandLineParser);
        }
        public CommandLineParser.CommandLineParser InitForRegexValueArgument()
        {
            var commandLineParser = new CommandLineParser.CommandLineParser();

            regexTarget = new RegexValueArgumentParsingTarget();
            commandLineParser.ExtractArgumentAttributes(regexTarget);

            return(commandLineParser);
        }
示例#33
0
        public static void Main(string[] args1)
        {
            var argsParser = new CommandLineParser.CommandLineParser();
            var args = new Options { };
            argsParser.ExtractArgumentAttributes(args);
            try { argsParser.ParseCommandLine(args1); }
            catch (Exception e) { Console.WriteLine(e.Message); return; }
            
            if (args.debug)
            {
                _debug = true;
                Console.WriteLine("[!] DEBUG mode on");
            }
            if (string.IsNullOrEmpty(args.username))
            {
                Console.WriteLine("[!] DEBUG mode on");
                return;
            }

            set_location(args.location);

            var access_token = login_ptc(args.username, args.password);
            if (access_token == null)
            {
                Console.WriteLine("[-] Wrong username/password");
                return;
            }
            Console.WriteLine("[+] RPC Session Token: {0} ...", access_token);

            var api_endpoint = get_api_endpoint(access_token);
            if (api_endpoint == null)
            {
                Console.WriteLine("[-] RPC server offline");
                return;
            }
            Console.WriteLine("[+] Received API endpoint: {0}", api_endpoint);

            var profile = get_profile(api_endpoint, access_token);
            if (profile != null)
            {
                Console.WriteLine("[+] Login successful");
                var profile2 = profile.Payload[0].Profile;
                Console.WriteLine("[+] Username: {0}", profile2.Username);
                var creationTime = FromUnixTime(profile2.CreationTime);
                Console.WriteLine("[+] You are playing Pokemon Go since: {0}", creationTime);
                foreach (var curr in profile2.Currency)
                    Console.WriteLine("[+] {0}: {1}", curr.Type, curr.Amount);
            }
            else {
                Console.WriteLine("[-] Ooops...");
            }
        }