nexus-cli icon indicating copy to clipboard operation
nexus-cli copied to clipboard

For the -keep option, is it possible to do a numeric sort?

Open DavidRodHub opened this issue 7 years ago • 2 comments

Great tool. Nice to be able to delete images from the nexus registry from the comand line. Is it possible to do a numeric (ie. version) sort when using the --keep option.

For example when I list the tags of an image I get:

  • 1.0.1
  • 1.0.11
  • 1.0.4
  • latest There are 4 images for repository xx

Then do the -keep 2 option, I get:

  • 1.0.4
  • latest

Would like to keep the last 2 versions:

  • 1.0.11
  • latest

DavidRodHub avatar Dec 13 '17 20:12 DavidRodHub

I can imagine that won't work with the current implementation, as the repository//v2//tags/list sorts the query alphabetically, not by updated date or numerical. You could use the swagger-ui, which does output the assets sorted by updated timestamp. In your case: you should have strict naming conventions for the versions. Those are not used on dockerhub as well. See eg. https://hub.docker.com/r/library/ubuntu/tags/>.

tallandtree avatar Jan 18 '18 09:01 tallandtree

Sorta old question, but I just sent a PR fixing this: https://github.com/mlabouardy/nexus-cli/pull/16 Maybe you could use my fork, until it gets merged.

nicovillanueva avatar Apr 13 '18 17:04 nicovillanueva