Tyrrrz / CliFx

Class-first framework for building command-line interfaces
MIT License
1.5k stars 61 forks source link

Force debug launch #63

Closed BlackGad closed 4 years ago

BlackGad commented 4 years ago

Hm it is strange, but you merged pull request with active debug prompt and 3 days ago removed that functionality. Is it merge errors or you decided to remove this functionality?

Tyrrrz commented 4 years ago

I refactored it a bit so that it's on by default and there's no option to disable it. The way it works is:

  1. Use [debug] directive.
  2. App tries to launch the debugger, which shows a prompt. It waits until you choose a debugger and click OK or just click Cancel.
  3. If you click OK, the debugger opens with a breakpoint triggered on that line.
  4. If you click cancel, it will print its PID and wait for a debugger to get attached.
BlackGad commented 4 years ago

It is bad for my case. Can you provide option to bypass passive debugger await? I wrap CLI tool with another application and if user want it can prompt debug launch. But if user cancels that dialog - it is expected that CLI will continue to execute in normal mode.

Tyrrrz commented 4 years ago

Why are you passing the debug directive to the wrapped CLI tool if you're not planning to have a debugger attached to it? The way it was designed is that you use this directive if you're running the CLI from outside your normal development environment (e.g. in production) if you need to attach the debugger. Otherwise you simply don't pass it.

BlackGad commented 4 years ago

Option is check box on UI. Often you just forget to uncheck it :) In passive mode with overridden output without window command just hangs. You have no mechanism to break that waiting externally. And this is issue for me :(

Tyrrrz commented 4 years ago

Maybe you should have it unchecked by default? When you pass the debug directive, the application will not proceed without a debugger, this is be design. You should pass this argument only when you need it, which shouldn't be a default or common occasion.

BlackGad commented 4 years ago

Maybe, but from my point of view it is reasonable to give ability for clients of this cli framework to control such options. Of course I might be wrong %)

Tyrrrz commented 4 years ago

You always want to keep the amount of configuration at minimum. The more variables you have, the harder it is to understand what went wrong if something breaks. So in that regard, opinionated design choices often lead to more maintainable software.

In this case I think the debug directive just should not be used as a default option. Its intent is very explicit: "please run the command with the debugger attached", so it makes sense that the command won't run without a debugger. If you don't want to debug it, then you should not pass that directive. :)

BlackGad commented 4 years ago

Ok, so maybe it will be nice to provide wait timeout? By default it will be infinite. It can be option in console application or debug argument extension like [debug:time]

Tyrrrz commented 4 years ago

No, because that's more or less the same thing. It really boils down to "if you don't want to launch in debug mode, don't pass the debug directive". I don't think letting the app run in debug mode but then not having the debugger attached makes sense at all. Sorry.