jfecher / ante

A safe, easy systems language
http://antelang.org
MIT License
1.9k stars 79 forks source link

CLI improvements #136

Closed ehllie closed 2 years ago

ehllie commented 2 years ago

Ideas for changes so far

Overhauling the cli by splitting the functionality into 3 sub-commands:

Additionally, a new functionality inside the sub-command completions which just allows for automatically generating code completion scripts with clap_complete

135

jfecher commented 2 years ago

Adding support for command line completion would be great, is there any way we can do it without changing the default of ante run ... though?

ehllie commented 2 years ago

I went for separating the cli into sub-commands, to clearly differentiate between which options are compatible with one another, but it should also be possible to achieve with argument relations

ehllie commented 2 years ago

https://user-images.githubusercontent.com/20847625/194134698-357cc935-2188-4018-8a27-ccb184a45494.mp4

This is what I have so far

ehllie commented 2 years ago

I can alternatively try doing something like this:

That should preserve the current functionality, add some extra check and allow for generating syntax completion.

jfecher commented 2 years ago

That sounds better. As far as prioritization goes, I think the most important aspects are (in order):

  1. Getting some command line completion working
  2. Maintaining the current command line syntax, or keeping it flexible for the future. E.g. a large change that will eventually be necessary is forwarding all arguments after the filename when running a file to the argv of that program. So that you could invoke it via ante myecho.an this is echoed.
  3. Ease of using the clap/cli API for the developer, brevity of code etc. If it requires too much code it may not be worth it for such a simple thing.
  4. Least important to me is preventing mutually conflicting options like check and run. I think most of these should be fairly obvious to users that they are conflicting, but an explicit error would always be nice.
ehllie commented 2 years ago

This PR is a little more conservative now.