Tyrrrz / CliFx

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

Interactive CLI and many other changes #74

Closed adambajguz closed 4 years ago

adambajguz commented 4 years ago

This pull request introduces a lot of changes, which have their origin in https://github.com/Tyrrrz/CliFx/issues/72 (@jim-wilson-kt). The newly introduced to CliFx interactive mode allows to build applications like mssql-cli or Azure CLI. Since interactive mode is optional and has its implementation in separate class CliInteractiveApplication, applications with permanently disabled interactive mode would not have any performance overhead due to the interactive mode.

Initially, I didn't want to remove ITypeActivator but I have found that keeping it lowers the flexibility of the framework, and since ASP.NET Core MVC also uses Microsoft.Extensions.DependencyInjection, I don't think this might be a problem. In my opinion, this change makes CliFx to be more a framework than before.

Changes:

PS. I put a lot of work into making all of the changes. However, since I have introduced a great deal of changes, sth might not be ideal. Feel free to comment or modify!

jim-wilson-kt commented 4 years ago

@adambajguz Thanks for the code contribution. I ran the CliFx.InteractiveModeDemo.dll and did not experience interactivity. In other words, the application showed the help and went back to the command prompt. Is an initial command required to trigger interactivity? By the way, for what it's worth, if @Tyrrrz accepts the pull request, I would be happy to update documentation.

adambajguz commented 4 years ago

This is explained in readme. You need '[interactive]' directive. This is to ensure you can use applicate as previously, i.e. as a cli tool. There should be also a launch profile in demo project with this already configured. You can also do sth like '[interactive] command'. This will execute command and then show prompt.

adambajguz commented 4 years ago

Hmm, maybe there should be some configuration to allow startup in interactive mode by default, thus not support tool aka normal mode at all?

Tyrrrz commented 4 years ago

Hi @adambajguz. Thanks for the PR.

This is a massive set of changes and, as it stands, it's almost impossible to review properly due to its size. There are too many unrelated changes mixed in, so it would be better to split it up into multiple branches.

Some high level comments:

adambajguz commented 4 years ago

Hi @Tyrrrz, thanks for comments :)

I'm not sure if this is a good idea to split the changes into multiple branches, as almost all of the changes depend on each other. Making separate branches would mean than I would have to spend another week on copying and adjusting the code.

I will close the PR for now, and reconsider both the changes and Something like adambajguz.CliFx.Interactive? (maybe since CliFx is MIT-licensed the best option is to publish a new package) ;)

Tyrrrz commented 4 years ago

I see, thanks for the reply.

I think design changes should be taken incrementally, in very small steps. A PR with 215 changed files is a no-starter, unfortunately. :)

...with the current design, especially CliApplicationBuilder class, this is not possible.

I would be happy to discuss what should be added in order to make it possible, as it seems to be the better approach. That way the framework would be open for extension and use cases such as yours can benefit from it.

maybe since CliFx is MIT-licensed the best option is to publish a new package

You are also welcome to do that.

adambajguz commented 4 years ago

For anyone who might be interested what have happened with my changes: >> Typin <<