question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make command line GNU-compatible

See original GitHub issue

While trying to implement zsh completion for Paket I found that the way Paket handles command line arguments is a bit off to what zsh regards as “the right way” which in turn makes implementing completion overly complex. I also found that some strings Paket accepts as arguments are (for reasons beyond my understanding) not written as such.

Take for example this line:

paket add nuget NUnit group Test project Foo.csproj --verbose --force

What’s the command and what are parameters?

  • add nuget is the command
  • group is an argument
    • Test is a parameter to the group argument
  • project is an argument
    • Foo.csproj is a parameter to the group argument
  • --verbose is an argument that takes no parameters
  • --force is an argument that takes no parameters

So how should command line completion distinct between command and arguments (with or without parameters)? The short answer is that it can’t. At least, I was not able to make it work with zsh without going great lengths and essentially reimplement the standard GNU-style arguments completion that ships with zsh (a 16KB function).

My suggestion is to align the command line to GNU-style:

paket add nuget NUnit --group Test --project Foo.csproj --verbose --force
paket add nuget NUnit --group=Test --project=Foo.csproj --verbose --force

Both should be regarded as the same. If the second line won’t be parsed by Argu, that’s fine with me as well.

I know this results in a breaking change, I suggest this to be planned for v4.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
agrosscommented, Jun 13, 2017

I spent some time to work on my zsh completion and GNU-style args for paket add. Feedback is appreciated!

https://asciinema.org/a/76d0gjmogm7f0vxntx05f2u94

0reactions
enricosadacommented, Jan 24, 2018

Fixed

USAGE: paket add [--help] [--version <version constraint>] [--project <path>] [--group <name>]
                 [--create-new-binding-files] [--force] [--interactive] [--redirects] [--clean-redirects]
                 [--no-install] [--no-resolve] [--keep-major] [--keep-minor] [--keep-patch] [--touch-affected-refs]
                 <package ID>

NUGET:

    <package ID>          NuGet package ID

OPTIONS:

    --version, -V <version constraint>
                          dependency version constraint
    --project, -p <path>  add the dependency to a single project only
    --group, -g <name>    add the dependency to a group (default: Main group)
    --create-new-binding-files
                          create binding redirect files if needed
    --force, -f           force download and reinstallation of all dependencies
    --interactive, -i     ask for every project whether to add the dependency
    --redirects           create binding redirects
    --clean-redirects     remove binding redirects that were not created by Paket
    --no-install          do not modify projects
    --no-resolve          do not resolve
    --keep-major          only allow updates that preserve the major version
    --keep-minor          only allow updates that preserve the minor version
    --keep-patch          only allow updates that preserve the patch version
    --touch-affected-refs touch project files referencing affected dependencies to help incremental build tools
                          detecting the change
    --silent, -s          suppress console output
    --verbose, -v         print detailed information to the console
    --log-file <path>     print output to a file
    --from-bootstrapper   call coming from the '--run' feature of the bootstrapper
    --help                display this list of options.
Read more comments on GitHub >

github_iconTop Results From Across the Web

GNU make
The make utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them. This ...
Read more >
GNU Make - Writing the Commands in Rules
GNU make knows how to execute several commands at once. Normally, make will execute only one command at a time, waiting for it...
Read more >
Make Compatibility
Almost all GNU Make and NMAKE options are valid for use with ElectricAccelerator. However, ElectricAccelerator does not support some GNU Make and NMAKE...
Read more >
Linux make Command with Examples
The make command and Makefiles speed up the compilation process. Read this guide to learn how to use the Linux make command with...
Read more >
make(1) - Linux man page
The purpose of the make utility is to determine automatically which pieces of a large program need to be recompiled, and issue the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found