public bool ShouldRunCounter(CommandLineArgumentsParser parser, out NotRunReason notRunReason)
        {
            notRunReason = NotRunReason.None;

            if (!parser.IsValidNumberOfArguments())
            {
                notRunReason = NotRunReason.InvalidNumberOfArguments;
                return(false);
            }

            if (parser.IsHelp())
            {
                notRunReason = NotRunReason.Help;
                return(false);
            }

            var path = parser.GetPath();

            var pathType = PathTypeDetection.GetPathType(path);

            if (pathType == PathType.Undefined)
            {
                notRunReason = NotRunReason.PathDoesNotExist;
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            var parser    = new CommandLineArgumentsParser(args);
            var printer   = new Printer();
            var validator = new ArgumentsValidator();

            NotRunReason reason;

            if (validator.ShouldRunCounter(parser, out reason))
            {
                var path           = parser.GetPath();
                var pathType       = PathTypeDetection.GetPathType(path);
                var fileExtensions = parser.GetFileExtensions();
                var linesCounter   = new PathLinesCounter(pathType, fileExtensions);

                var count = linesCounter.GetCount(path);

                printer.PrintLinesOfCode(count);
            }
            else
            {
                printer.Print(reason, parser);
            }
        }