I think it'd be cool if there was a helper command (something like rtx convert maybe) that checks the current working directory and if there is a .tool-versions file, it attempts to generate a .rtx.toml file from it. If a .rtx.toml file already exists in the current directory, the command could just print the generated .rtx.toml to the console so the user can manually copy-paste if they would prefer.
I made a bash alias for this:
function asdfToRtx() {
input=".tool-versions"
output=".rtx.toml"
declare -A language_map=(
["nodejs"]="node"
)
if [[ -e $output ]]; then
echo "[tools]"
else
echo "[tools]" > $output
fi
# Read the input file line by line
while IFS= read -r line
do
# Split the line into name and version
name=$(echo $line | awk '{print $1}')
version=$(echo $line | awk '{print $2}')
# Rename languages if needed
if [[ -n "${language_map[$name]}" ]]; then
name="${language_map[$name]}"
fi
line="$name = \"$version\""
if [[ -e $output ]]; then
echo $line
else
echo $line >> $output
fi
done < $input
}
we have mise cfg generate as a common that could probably use a --tool-versions option. This is an easy change if someone wants to contribute. We already have code that can be used to parse .tool-versions:
I think it'd be cool if there was a helper command (something like
rtx convert
maybe) that checks the current working directory and if there is a.tool-versions
file, it attempts to generate a.rtx.toml
file from it. If a.rtx.toml
file already exists in the current directory, the command could just print the generated.rtx.toml
to the console so the user can manually copy-paste if they would prefer.I made a bash alias for this: