Пример #1
0
        private bool TryParseArg(List <string> args, out GenArgs result, out string errMsg)
        {
            var helpWriter = new StringWriter();
            var parser     = new Parser(ps =>
            {
                ps.HelpWriter = helpWriter;
            });;
            var parseResult = parser.ParseArguments <GenArgs>(args);

            if (parseResult.Tag == ParserResultType.NotParsed)
            {
                errMsg = helpWriter.ToString();
                result = null;
                return(false);
            }

            result = (parseResult as Parsed <GenArgs>).Value;
            errMsg = null;
            return(true);
        }
Пример #2
0
        private bool TryParseArg(List <string> args, out GenArgs options, out string errMsg)
        {
            var helpWriter = new StringWriter();
            var parser     = new Parser(ps =>
            {
                ps.HelpWriter = helpWriter;
            });;
            var parseResult = parser.ParseArguments <GenArgs>(args);

            if (parseResult.Tag == ParserResultType.NotParsed)
            {
                errMsg  = helpWriter.ToString();
                options = null;
                return(false);
            }

            options = (parseResult as Parsed <GenArgs>).Value;
            errMsg  = null;

            if (!options.ValidateOutouptCodeDir(ref errMsg))
            {
                return(false);
            }
            if (options.GenType.Contains("typescript") && !options.ValidateTypescriptRequire(options.GenType, ref errMsg))
            {
                return(false);
            }
            if (options.GenType.Contains("go_") && !options.ValidateGoRequire(options.GenType, ref errMsg))
            {
                return(false);
            }
            if (!options.ValidateConvention(ref errMsg))
            {
                return(false);
            }
            return(true);
        }