示例#1
0
        public static void Main(string[] args)
        {
            var options = new Options();

            Parser.Default.ParseArgumentsStrict(args, options);

            if (options.LogLevel >= LogLevel.Debug)
            {
                Console.WriteLine($"File Parameter: '{options.File}'");
                Console.WriteLine($"File Count: {options.File?.Count ?? -1}");
                Console.WriteLine($"File Directory: '{options.Directory}'");
            }

            bool isFileOptionSpecified      = ((options.File?.Count ?? 0) != 0);
            bool isDirectoryOptionSpecified = !String.IsNullOrEmpty(options.Directory);

            if (isFileOptionSpecified ^ isDirectoryOptionSpecified)
            {
                var xamlStylerConsole = new XamlStylerConsole(options);
                xamlStylerConsole.Process(isFileOptionSpecified ? ProcessType.File : ProcessType.Directory);
            }
            else
            {
                var errorString = (isFileOptionSpecified && isDirectoryOptionSpecified)
                    ? "Cannot specify both file(s) and directory"
                    : "Must specify file(s) or directory";

                Console.WriteLine($"\nError: {errorString}\n");
                Console.WriteLine(options.GetUsage());
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            var options = new Options();

            Parser.Default.ParseArgumentsStrict(args, options);
            var xamlStylerConsole = new XamlStylerConsole(options);

            xamlStylerConsole.Process();
        }
示例#3
0
        public static void Main(string[] args)
        {
            var writer = new StringWriter();
            var parser = new Parser(_ => _.HelpWriter = writer);
            var result = parser.ParseArguments <Options>(args);

            result.WithNotParsed(_ =>
            {
                Console.WriteLine(writer.ToString());
                Environment.Exit(1);
            })
            .WithParsed(options =>
            {
                if (options.LogLevel >= LogLevel.Debug)
                {
                    Console.WriteLine($"File Parameter: '{options.File}'");
                    Console.WriteLine($"File Count: {options.File?.Count ?? -1}");
                    Console.WriteLine($"File Directory: '{options.Directory}'");
                }

                bool isFileOptionSpecified      = ((options.File?.Count ?? 0) != 0);
                bool isDirectoryOptionSpecified = !String.IsNullOrEmpty(options.Directory);

                if (isFileOptionSpecified ^ isDirectoryOptionSpecified)
                {
                    var xamlStylerConsole = new XamlStylerConsole(options);
                    xamlStylerConsole.Process(isFileOptionSpecified ? ProcessType.File : ProcessType.Directory);
                }
                else
                {
                    var errorString = (isFileOptionSpecified && isDirectoryOptionSpecified)
                        ? "Cannot specify both file(s) and directory"
                        : "Must specify file(s) or directory";

                    Console.WriteLine($"\nError: {errorString}\n");
                }
            });
        }