- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
template index is now stored locally and there is now a latest hash a…
…ttribute + some cleanup
Showing
29 changed files
with
368 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
#include <Frate/Frate.hpp> | ||
|
||
namespace Frate::Command { | ||
|
||
class CommandException : public FrateException { | ||
public: | ||
CommandException(const std::string &message) : FrateException(message) {} | ||
}; | ||
|
||
class MissingArgumentException : public CommandException { | ||
public: | ||
MissingArgumentException(const std::string &message) | ||
: CommandException(message) {} | ||
}; | ||
|
||
class InvalidArgumentValueException : public CommandException { | ||
public: | ||
InvalidArgumentValueException(const std::string &message) | ||
: CommandException(message) {} | ||
}; | ||
|
||
class InvalidArgumentTypeException : public CommandException { | ||
public: | ||
InvalidArgumentTypeException(const std::string &message) | ||
: CommandException(message) {} | ||
}; | ||
|
||
class InvalidCommandException : public CommandException { | ||
public: | ||
InvalidCommandException(const std::string &message) | ||
: CommandException(message) {} | ||
}; | ||
|
||
class InvalidSubcommandException : public CommandException { | ||
public: | ||
InvalidSubcommandException(const std::string &message) | ||
: CommandException(message) {} | ||
}; | ||
|
||
class ActionNotImplementedException : public CommandException { | ||
public: | ||
ActionNotImplementedException(const std::string &message) | ||
: CommandException(message) {} | ||
}; | ||
|
||
class HandlerNotImplementedException : public CommandException { | ||
public: | ||
HandlerNotImplementedException(const std::string &message) | ||
: CommandException(message) {} | ||
}; | ||
|
||
} // namespace Frate::Command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
#include "Frate/Command/Exceptions.hpp" | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace Frate::Command { | ||
class Interface; | ||
|
||
class CommandHandler { | ||
private: | ||
std::vector<std::string> aliases; | ||
std::vector<std::string> flags{}; | ||
std::vector<CommandHandler> subcommands{}; | ||
std::vector<std::string> positional_args{}; | ||
bool implemented{true}; | ||
bool requires_project{true}; | ||
bool unlimited_args{false}; | ||
std::string docs; | ||
std::shared_ptr<Interface> inter; | ||
|
||
public: | ||
CommandHandler(std::shared_ptr<Interface> inter) : inter(inter) {} | ||
|
||
virtual ~CommandHandler() = default; | ||
|
||
virtual void run() = 0; | ||
virtual void registerOptions() = 0; | ||
virtual void checkInput() = 0; | ||
|
||
// Checkers | ||
bool isImplemented() { return implemented; } | ||
bool requiresProject() { return requires_project; } | ||
bool hasUnlimitedArgs() { return unlimited_args; } | ||
|
||
// Getters | ||
std::vector<std::string> &getAliases() { return aliases; } | ||
std::vector<std::string> &getFlags() { return flags; } | ||
std::vector<CommandHandler> &getSubcommands() { | ||
return subcommands; | ||
} | ||
|
||
std::vector<std::string> &getPosArgs() { return positional_args; } | ||
std::string &getDocs() { return docs; } | ||
std::shared_ptr<Interface> &getInterface() { return inter; } | ||
}; | ||
|
||
} // namespace Frate::Command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#pragma once | ||
#include <Frate/Command/Exceptions.hpp> | ||
#include <Frate/CommandHandler.hpp> | ||
|
||
namespace Frate::Command { | ||
class TargetHandler { | ||
public: | ||
|
||
virtual void actionAdd() {} | ||
|
||
virtual void actionRemove() {} | ||
|
||
virtual void actionList() {} | ||
|
||
virtual void actionUpdate() {} | ||
|
||
virtual void actionSet() {} | ||
|
||
virtual void actionGet() {} | ||
|
||
virtual void actionSearch() {} | ||
|
||
}; | ||
|
||
class TargetPackageHandler : public TargetHandler, public CommandHandler { | ||
public: | ||
TargetPackageHandler(std::shared_ptr<Interface> inter) | ||
: CommandHandler(inter) {} | ||
|
||
~TargetPackageHandler() override = default; | ||
|
||
void run() override { | ||
|
||
} | ||
void registerOptions() override { | ||
|
||
} | ||
void checkInput() override { | ||
|
||
} | ||
void actionAdd() override {} | ||
void actionRemove() override {} | ||
void actionList() override {} | ||
void actionUpdate() override {} | ||
}; | ||
|
||
class TargetPackageIndexHandler : public TargetHandler, public CommandHandler { | ||
public: | ||
TargetPackageIndexHandler(std::shared_ptr<Interface> inter) | ||
: CommandHandler(inter) {} | ||
|
||
~TargetPackageIndexHandler() override = default; | ||
|
||
void run() override { | ||
|
||
} | ||
void registerOptions() override { | ||
|
||
} | ||
void checkInput() override { | ||
|
||
} | ||
void actionUpdate() override {} | ||
}; | ||
|
||
} // namespace Frate::Command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
#include <nlohmann/json.hpp> | ||
#include <string> | ||
|
||
namespace Frate::Project { | ||
|
||
class TemplateIndexEntry { | ||
private: | ||
std::string name; | ||
std::string description; | ||
std::string latest_hash; | ||
std::string git; | ||
|
||
public: | ||
friend void from_json(const nlohmann::json &j, TemplateIndexEntry &t); | ||
friend void to_json(nlohmann::json &j, const TemplateIndexEntry &t); | ||
|
||
std::string &getName() { return name; } | ||
|
||
std::string &getDescription() { return description; } | ||
|
||
std::string &getLatestHash() { return latest_hash; } | ||
|
||
std::string &getGit() { return git; } | ||
}; | ||
} // namespace Frate::Project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <Frate/Project/TemplateIndexEntry.hpp> | ||
#include <Frate/Utils/Logging.hpp> | ||
#include <Frate/Utils/Macros.hpp> | ||
|
||
namespace Frate::Project { | ||
void from_json(const nlohmann::json &json_obj, TemplateIndexEntry &template_obj){ | ||
FROM_JSON_FIELD(template_obj, name); | ||
FROM_JSON_FIELD(template_obj, description); | ||
FROM_JSON_FIELD(template_obj, latest_hash); | ||
FROM_JSON_FIELD(template_obj, git); | ||
} | ||
void to_json(nlohmann::json &json_obj, const TemplateIndexEntry &template_obj){ | ||
TO_JSON_FIELD(template_obj, name); | ||
TO_JSON_FIELD(template_obj, description); | ||
TO_JSON_FIELD(template_obj, latest_hash); | ||
TO_JSON_FIELD(template_obj, git); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters