gum
gum copied to clipboard
Allow specifying the min. version of `gum` required
Is your feature request related to a problem? Please describe.
The nature of CLI tooling means that the version of gum
being used is very important - older versions cannot know about the new behaviours of newer versions, and attempting to use an older version of gum
can result in an error that presents itself as the user being in the wrong (i.e. "--flag is not valid").
Describe the solution you'd like
Provide a command that allows specifying the version of gum
required, that people could stick at the start of their scripts and would print a message explaining that the version of gum
that would be used is not expected to be compatible, and potentially link / explain how to update.
i.e.
#!/bin/bash
gum version '0.12.0' # or '>= 0.12.0'
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Hello, there! Welcome to $(gum style --foreground 212 'Gum')."
NAME=$(gum input --placeholder "What is your name?")
echo -e "Well, it is nice to meet you, $(gum style --foreground 212 "$NAME")."
This could result in something like:
> gum/examples/demo.sh
This script requires gum 0.12.0, but you're using v0.8.0 - it would be best if you update to ensure you don't have any problems!
I think ideally it would be nice to support at least a basic constraint rather than requiring just a single specific version, but I think that could be supported later on.
Describe alternatives you've considered
I could attempt to check the version of gum
using built-ins, but I expect that will be tedious, potentially brittle, and just annoyingly large if we want to have a nice error message.
Additional context
While this kind of command itself wouldn't be present in earlier versions of gum
, the earlier the base command is added the easier it should be in the long-run to expand its support (i.e. if you just started with supporting static versions, the error message could mention "if you're trying to do constraints, you probably want a newer version of gum
")