informedcitizenry / 6502.Net

A .Net-based Cross-Assembler for Several 8-Bit Microprocessors
MIT License
58 stars 17 forks source link

[Request] Custom Args #6

Closed svallee-dev closed 4 years ago

svallee-dev commented 4 years ago

Me again! I just pulled your latest version (2.1.8.1) and it all works perfectly.

That being said I needed to add a small tweak to make it work in my non-CL context, and thought maybe you'd be interested in adding it to your codebase. Basically, "CommandLineOptions.cs" has an hardcoded behavior of pulling arguments from the command line array. In my non-CL project it's not working, of course. So what I did is:

1) In AssemblyController.cs I'm adding an optional argument, which I pass to Assembler.Initialize.

        public AssemblyController(List<string> args = null)
        {
            Assembler.Initialize(args);
            _assemblers = new List<AssemblerBase>();
        }

2) In Assembler.cs I pass the argument along:

        public static void Initialize(List<string> args)
        {
            ...
            Options.ParseArgs(args);

3) And finally in CommandLineOptions.cs:

        public void ParseArgs(List<string> args = null)
        {
            args = args ?? Environment.GetCommandLineArgs().Skip(1).ToList();

I'm not quit sure if you're interested in supporting this paradigm, and it not, by all mean ignore my request and close this bug entry. I can maintain this change in my local project. Just thought I'd let you know in case you are interested :)

informedcitizenry commented 4 years ago

My primary vision for this tool is for it to be a native app invoked in a command line. That said, I am open to exploring generalizing it to more of a service that you could invoke through other contexts. Obviously your changes would have to be a part of that, but I would also want to do deeper analysis, including looking at concurrency issues, for instance. Thanks again for your feedback.

FYI, I have a new update that completely changes the options. I am now leveraging a third party package for it, because I was generally not satisfied with my own solution. Take a look!

informedcitizenry commented 4 years ago

I have changed the initialization so now that an args collection must be passed through, and we're no longer looking at the environment state.