Skip to content

Commit

Permalink
Merge pull request #5 from SoHugePenguin/main
Browse files Browse the repository at this point in the history
Fix java version recognition and console prompts
  • Loading branch information
SoHugePenguin authored Jan 7, 2025
2 parents d16b6bb + 2785ed9 commit e13c7df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/base/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CommandExecutionException : public BaseException {
class ParserException : public BaseException {
public:
explicit ParserException(std::string_view raw_str, std::string_view message)
: BaseException(fmt::format("[exception.parser] (str: {}) {}")) {}
: BaseException(fmt::format("[exception.parser] (str: {}) {}", raw_str, message)) {}
};

class NeedUpdateException : public BaseException {
Expand Down
19 changes: 13 additions & 6 deletions src/base/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@ namespace allay_launcher {

std::optional<Version> Version::parse(std::string_view str) {
auto tokens = util::string::split(str, ".");
if (tokens.size() < 3) {
if (tokens.size() > 3) {
return {};
}

auto major = util::string::to_int32(tokens.at(0));
auto minor = util::string::to_int32(tokens.at(1));
auto revision = util::string::to_int32(tokens.at(2));
// major(require),minor,revision
std::vector<std::optional<int32_t>> version = {0, 0, 0};

if (!major || !minor || !revision) return {};
auto vId = 0;
for (const auto& item : tokens) {
version[vId] = util::string::to_int32(tokens[vId]);
vId++;
}

return Version{*major, *minor, *revision};
if (!version[0]) return {};
auto ret = Version{*version[0], 0, 0};
if (version[1]) ret.m_minor = *version[1];
if (version[2]) ret.m_revision = *version[2];
return ret;
}

} // namespace allay_launcher

0 comments on commit e13c7df

Please sign in to comment.