Hello, recently I’m thinking about a new feature for my software. I would like to make it able to change to an another version by itself (older or newer).
My software name is ISM. For example:
ism version switch Alpha-06012023
I would like if I type this on the terminal, my software compile itself.
Because I tried something like that, but it doesn’t work (I was almost sure about that). I just show you to get the idea about what I would like to do:
module ISM
module Option
class VersionSwitch < ISM::CommandLineOption
def initialize
super( ISM::Default::Option::VersionSwitch::ShortText,
ISM::Default::Option::VersionSwitch::LongText,
ISM::Default::Option::VersionSwitch::Description,
Array(ISM::CommandLineOption).new)
end
def start
if ARGV.size == 2+Ism.debugLevel
showHelp
else
currentVersion = ARGV[2+Ism.debugLevel]
processResult = IO::Memory.new
process = Process.run("git",args: [ "describe",
"--all"],
output: processResult)
previousVersion = processResult.to_s.strip
previousVersion = previousVersion.lchop(previousVersion[0..previousVersion.rindex("/")])
process = Process.run("git",args: [ "switch",
"--detach",
currentVersion])
if !process.success?
process = Process.run("git",args: [ "switch",
currentVersion])
end
process = Process.run("crystal",args: [ "build",
"Main.cr",
"-o",
"ism"])
process = Process.run("git",args: [ "update-ref",
"-d",
"/refs/heads/#{previousVersion}"])
end
end
end
end
end
So how do you suggest can I proceed ?