Пример #1
0
        private static void Run(MessageLog messageLog, CommandLineArgs cmd)
        {
            if (stringComparer.Compare(cmd.operation, "doc") == 0)
            {
                MakeDoc(cmd.outputFile, cmd.rawsFolder, cmd.rawsExtension, cmd.isDirectory, cmd.docHeader, cmd.docFooter);
            }
            else if (stringComparer.Compare(cmd.operation, "plusplus") == 0)
            {
            #if !DEBUG
                throw new NotImplementedException();
            #endif
                LoadCodes(cmd.rawsFolder, cmd.rawsExtension, cmd.isDirectory, false);

                EACodeLanguage language;
                if (languages.TryGetValue(cmd.language, out language))
                {
                    HighlightingHelper.GetNotepadPlusPluslanguageDoc(language, cmd.outputFile);
                }
            }
            else if (stringComparer.Compare(cmd.operation, "prognotepad") == 0)
            {
                LoadCodes(cmd.rawsFolder, cmd.rawsExtension, cmd.isDirectory, false);

                HighlightingHelper.GetProgrammersNotepadlanguageDoc(languages.Values, cmd.outputFile);
            }
            else
            {
                LoadCodes(cmd.rawsFolder, cmd.rawsExtension, cmd.isDirectory, false);

                if (languages.ContainsKey(cmd.language))
                {
                    if (stringComparer.Compare(cmd.operation, "A") == 0)
                    {
                        Assemble(cmd.inputFile, cmd.outputFile, cmd.language, messageLog);
                    }
                    else if (stringComparer.Compare(cmd.operation, "D") == 0)
                    {
                        Disassemble(
                            cmd.inputFile,
                            cmd.outputFile,
                            cmd.language,
                            cmd.addEndGuards,
                            cmd.disassemblyMode.Value,
                            cmd.offset.Value,
                            cmd.priority.HasValue ? cmd.priority.Value : Priority.none,
                            cmd.size.HasValue ? cmd.size.Value : 0,
                            messageLog);
                    }
                    else messageLog.AddError("{0} is not a valid operation.", cmd.operation);
                }
                else messageLog.AddError("{0} is not a valid language", cmd.language);
            }
        }
Пример #2
0
        //StdOut - output
        //StdIn - input
        //StdError - errors and messages
        //0 - D, A or Doc, assemble, disassemble or doc generation
        //1 - language (assembly or disassembly only)
        //2 - disassembly mode (disassembly only)
        //3 - offset to disassemble (disassembly only)
        //4 - priority to disassemble (disassembly only)
        //5 - length to disassemble (disassembly only)
        //flags: -addEndGuards
        //       -raws:Folder or file
        //       -rawsExt:extension
        //       -output:File
        //       -input:File
        //       -error:File
        //       -docHeader:File
        //       -docFooter:File
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                return;
            }

            var messageLog = new MessageLog(1000);

            //var cmd = HandleFlags(flags, messageLog);
            var cmd = new CommandLineArgs();
            var error = cmd.SetArgs(args);

            if (!error.CausedError)
            {
                try
                {
                    Run(messageLog, cmd);
                }
                catch (Exception e)
                {
                    messageLog.AddError(e.Message);
                }
            }

            if (cmd.errorFile != null)
            {
                using (var writer = new StreamWriter(cmd.errorFile))
                {
                    messageLog.WriteToStream(writer);
                }
            }
            else
            {
                messageLog.WriteToStream(Console.Error);
            }
            messageLog.Clear();
        }