Closed marcelldls closed 3 months ago
Usage:
(.venv) [esq51579@pc0146 ibek]$ ibek version below 2.2.1 && echo Continue
SUCCESS: IBEK 2.0.2.dev0+g928f52e2.d20240402 less than 2.2.1
Continue
(.venv) [esq51579@pc0146 ibek]$ ibek version above 2.2.1 && echo Continue
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/esq51579/WIP/pr/ibek/src/ibek/version_cmds/commands.py:40 in above │
│ │
│ 37 │ if Version.coerce(__version__) > Version.coerce(in_ver): │
│ 38 │ │ print(f"SUCCESS: IBEK {__version__} greater than {in_ver}") │
│ 39 │ else: │
│ ❱ 40 │ │ raise Exception(f"IBEK {__version__} not greater than {in_ver}") │
│ 41 │
│ 42 │
│ 43 @version_cli.command() │
│ │
│ ╭───── locals ─────╮ │
│ │ in_ver = '2.2.1' │ │
│ ╰──────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
Exception: IBEK 2.0.2.dev0+g928f52e2.d20240402 not greater than 2.2.1
Hows something like:
(.venv) [esq51579@pc0146 ibek]$ if ibek compare 1.1.1 "<" 1.1.2; then echo continue; fi
continue
(.venv) [esq51579@pc0146 ibek]$ if ibek compare 1.1.1 ">" 1.1.2; then echo continue; fi
Have you considered copying pip's requirements specifier syntax rather than "below", "above", etc.?
https://pip.pypa.io/en/stable/reference/requirement-specifiers/
You could have a command that takes a package and a specifier that covers all cases, e.g. ibek ... $BASE >=7.0.8
or ibek ... $BASE <7.0.8
I think checking ibek itself might be better as a separate command.
Have you considered copying pip's requirements specifier syntax rather than "below", "above", etc.?
https://pip.pypa.io/en/stable/reference/requirement-specifiers/
You could have a command that takes a package and a specifier that covers all cases, e.g.
ibek ... $BASE >=7.0.8
oribek ... $BASE <7.0.8
I think checking ibek itself might be better as a separate command.
Thanks @GDYendell. Was just to get something simple out quickly to discuss really.
Your proposal makes sense. Because of "Use quotes around specifiers in the shell when using >, <, or when using environment markers" I believe your proposal would actually be ibek ... $BASE ">=7.0.8"
. But fine with that @gilesknap
Agree "checking ibek itself might be better as a separate command"
@gilesknap Thoughts? Usage
(.venv) [esq51579@pc0146 ibek]$ if ibek compare "1.1.3" ">1.1.2"; then echo continue; fi
continue
(.venv) [esq51579@pc0146 ibek]$ if ibek compare "1.1.3" "<1.1.2"; then echo continue; fi
Yes very happy with that - now the question is how to do ibek itself. One way would be:
if ibek compare $(ibek --version) ">2.0.0"; then echo continue; fi
Too ugly? @GDYendell?
BTW I assume with this syntax you will support >= >= == too ?
Or maybe all of these ? https://pip.pypa.io/en/stable/reference/requirement-specifiers/#examples
BTW I assume with this syntax you will support >= >= == too ?
Or maybe all of these ? https://pip.pypa.io/en/stable/reference/requirement-specifiers/#examples
Right now I have https://github.com/epics-containers/ibek/blob/db28c9e2b4a6bab38d6171ed4868da3d8adba138/src/ibek/commands.py#L10-L16
if ibek compare $(ibek --version) ">2.0.0"; then echo continue; fi
Too ugly? @GDYendell?
I think this is OK. I like it more than ibek compare
implicitly checking ibek if you only give it the version specifier.
Like it !
Thoughts @gilesknap?