Skip to content

Commit

Permalink
removed some scuff added key checker for frate-project.json
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaSTL committed Dec 1, 2023
1 parent a5677ed commit d63ca19
Show file tree
Hide file tree
Showing 36 changed files with 197 additions and 1,635 deletions.
7 changes: 7 additions & 0 deletions cpm-package-lock.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ CPMDeclarePackage(libgit2
# OPTIONS
# "ENABLE_VERSIONED_SYMBOLS ON"
#)
# cpptrace
CPMDeclarePackage(cpptrace
VERSION 0.2.1
GITHUB_REPOSITORY jeremy-rifkin/cpptrace
SYSTEM YES
EXCLUDE_FROM_ALL YES
)
70 changes: 3 additions & 67 deletions include/Frate/Command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ namespace Command {
Mode{.name= "Test", .flags={"-g"}}
};
std::vector<std::string> authors;
std::vector<std::string> keywords;
std::string src_dir{"src"};
std::string include_dir{"include"};
std::vector<RemoteServer> build_servers;
Expand All @@ -113,6 +114,8 @@ namespace Command {
std::vector<std::string> toolchains {};
void fromJson(json j);
nlohmann::json toJson();
bool writeConfig();
void checkKeys(json j);
} Project;
typedef struct Handler_s Handler;
typedef struct Handler_s {
Expand All @@ -132,58 +135,13 @@ namespace Command {
} Handler;

class Interface{
private:
//Commands;
//TODO: We really should define top level commands as seperate modules
bool init();
[[deprecated("use Command::Actions::Add::run instead")]]
bool add();
[[deprecated("use Command::Actions::Get::run instead")]]
bool get();
[[deprecated("use Command::Actions::Set::run instead")]]
bool set();
[[deprecated("use Command::Actions::Remove::run instead")]]
bool remove();
[[deprecated("use Command::Actions::Update::run instead")]]
bool update();
[[deprecated("use Command::Actions::Run::run instead")]]
bool run();
[[deprecated("use Command::Actions::Help::run instead")]]
bool help();
[[deprecated("use Command::Actions::Search::run instead")]]
bool search();
[[deprecated("use Command::Actions::FTP::run instead")]]
bool ftp();
[[deprecated("use Command::Actions::Watch::run instead")]]
bool watch();
[[deprecated("use Command::Actions::Clean::run instead")]]
bool clean();
[[deprecated("use Command::Actions::Build::run instead")]]
bool build();
[[deprecated("use Command::Actions::List::run instead")]]
bool list();
public:
void getHelpString(std::string name,std::vector<Handler> &handlers,bool is_subcommand = false);
void getHelpString(Handler &handler);
bool runCommand(std::string,std::vector<Handler>&);
std::shared_ptr<Project> pro;
bool project_present{false};
std::vector<Handler> commands{};
//All sub command getters
[[deprecated("use Command::Actions::handlers instead")]]
std::vector<Handler> getAddHandlers();
[[deprecated("use Command::Actions::handlers instead")]]
std::vector<Handler> getGetHandlers();
[[deprecated("use Command::Actions::handlers instead")]]
std::vector<Handler> getSetHandlers();
[[deprecated("use Command::Actions::handlers instead")]]
std::vector<Handler> getListHandlers();
[[deprecated("use Command::Actions::handlers instead")]]
std::vector<Handler> getSearchHandlers();
[[deprecated("use Command::Actions::handlers instead")]]
std::vector<Handler> getRemoveHandlers();
[[deprecated("use Command::Actions::handlers instead")]]
std::vector<Handler> getUpdateHandlers();

bool execute();
bool skip_prompts{false};
Expand All @@ -201,29 +159,7 @@ namespace Command {
};

namespace OptionsInit{
//Top level commands
//TODO: We really should decouple the options from top level commands
bool Init(Interface*);
bool Search(Interface*);
bool Add(Interface*);
bool Set(Interface*);
bool Remove(Interface*);
bool Update(Interface*);
bool Watch(Interface*);
bool Clean(Interface*);
bool List(Interface*);
bool Build(Interface*);
bool Main(Interface*);


[[deprecated("put options in the specific module")]]
bool Server(Interface*);
[[deprecated("put options in the specific module")]]
bool Packages(Interface*);
[[deprecated("put options in the specific module")]]
bool Flags(Interface*);
[[deprecated("put options in the specific module")]]
bool Mode(Interface*);
};

std::string downloadIndex();
Expand Down
7 changes: 7 additions & 0 deletions include/Frate/Command/Keywords.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <Frate/Command.hpp>
namespace Command::Keywords {
bool options(Interface* inter);


bool add(Interface* inter);
}
2 changes: 1 addition & 1 deletion include/Frate/Command/Modes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Command{
bool add(Interface* interface);
bool remove(Interface* interface);
bool list(Interface* interface);
bool Options(Interface* interface);
bool options(Interface* interface);
}
}

7 changes: 7 additions & 0 deletions include/Frate/Command/Name.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <Frate/Command.hpp>

namespace Command::Name {

bool options(Interface* inter);
bool set(Interface* inter);
}
5 changes: 0 additions & 5 deletions include/Frate/Command/Set.hpp

This file was deleted.

1 change: 1 addition & 0 deletions include/Frate/Generators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace Generators{
std::string lang_version;
std::string authors_str;
} Config;
[[deprecated("Use project->writeConfig() instead")]]
bool writeConfig(std::shared_ptr<Command::Project>& ctx);
}

Expand Down
12 changes: 11 additions & 1 deletion src/Command/Actions/Add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <Frate/Command/Package.hpp>
#include <Frate/Command/Flags.hpp>
#include <Frate/Command/Toolchains.hpp>
#include <Frate/Command/Keywords.hpp>
#include <Frate/Command/Author.hpp>
#include <Frate/Command/Modes.hpp>
#include <Frate/Command/RemoteServers.hpp>
Expand Down Expand Up @@ -75,7 +76,7 @@ namespace Command::Add {
.positional_args = {"mode-name"},
.docs = "Adds a build mode to your project",
.callback = [inter]() {
Modes::Options(inter);
Modes::options(inter);
return Modes::add(inter);
},
},
Expand Down Expand Up @@ -112,6 +113,15 @@ namespace Command::Add {
return Author::add(inter);
},
},
Handler{
.aliases = {"keywords","kw"},
.positional_args = {"keyword,..."},
.docs = "Add keywords to your project",
.callback = [inter]() {
Keywords::add(inter);
return false;
},
},
};
}
}
2 changes: 1 addition & 1 deletion src/Command/Actions/Remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Command::Remove {
.positional_args = {"mode"},
.docs = "Remove a mode from the project",
.callback = [inter]() {
Modes::Options(inter);
Modes::options(inter);
return Modes::remove(inter);
},
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Actions/Set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <Frate/Command/Actions/Set.hpp>
#include <Frate/Command/Flags.hpp>
#include <Frate/Command/License.hpp>
#include <Frate/Command/Name.hpp>
#include <Frate/Command/RemoteServers.hpp>
#include <Frate/Command/Set.hpp>
namespace Command::Set {

bool options(Interface *inter) {
Expand All @@ -30,7 +30,7 @@ namespace Command::Set {
.aliases = {"name","n"},
.docs = "Set the project's name",
.callback = [inter]() {
name(inter);
Name::set(inter);
return true;//Name::set(inter);
},
},
Expand Down
13 changes: 11 additions & 2 deletions src/Command/Author/Author.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@

namespace Command::Author {


bool options(Interface *inter){
inter->InitHeader();
inter->options->parse_positional({"command","subcommand","args"});
inter->options->add_options()
("command", "Command to run", cxxopts::value<std::string>())
("subcommand", "Subcommand to run", cxxopts::value<std::string>())
("args", "Authors", cxxopts::value<std::vector<std::string>>());
return true;
}
bool add(Interface *inter){
if (inter->pro->args->count("args") == 0) {
options(inter);
if (inter->pro->args->count("args") > 0) {
for (auto author : inter->pro->args->operator[]("args").as<std::vector<std::string>>()) {
inter->pro->authors.push_back(author);
}
Expand Down
159 changes: 0 additions & 159 deletions src/Command/CommandAdd.cpp

This file was deleted.

Loading

0 comments on commit d63ca19

Please sign in to comment.