Minor improvements and fixes.

test/nbt_helpers: add a headline to output
Build system: remove comma from array that I added bc I thought it was correct sytax, it wasn't
lib/cli: change argument order of PositionalArgument constructor to fit in with Flag and UnpositionalArgument
lib/cli: properly define what is private and what is public in the ArgumentsParser class
BodgeMaster-unfinished
BodgeMaster 2022-07-15 08:46:53 +02:00
parent 390087fc35
commit a1223ea4b9
4 changed files with 26 additions and 21 deletions

View File

@ -72,7 +72,7 @@ echo "Building tools..."
mkdir -pv bin/tools mkdir -pv bin/tools
# add compile commands to this array # add compile commands to this array
COMPILE_COMMANDS=( COMPILE_COMMANDS=(
"$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -Lbin/lib -l:nbt.so -o bin/tools/dumpnbt", "$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -Lbin/lib -l:nbt.so -o bin/tools/dumpnbt"
"$CXX_WITH_FLAGS src/tools/hexnet.cpp -Ldependencies/sockpp-0.7.1/build -l:libsockpp.so -Idependencies/sockpp-0.7.1/include -o bin/tools/hexnet" "$CXX_WITH_FLAGS src/tools/hexnet.cpp -Ldependencies/sockpp-0.7.1/build -l:libsockpp.so -Idependencies/sockpp-0.7.1/include -o bin/tools/hexnet"
) )
for command in ${!COMPILE_COMMANDS[@]}; do for command in ${!COMPILE_COMMANDS[@]}; do

View File

@ -46,7 +46,7 @@ namespace CLI {
PositionalArgument::PositionalArgument() { PositionalArgument::PositionalArgument() {
this->present = false; this->present = false;
} }
PositionalArgument::PositionalArgument(std::string description, std::string placeholder) { PositionalArgument::PositionalArgument(std::string placeholder, std::string description) {
this->description = description; this->description = description;
this->placeholder = placeholder; this->placeholder = placeholder;
this->present = false; this->present = false;

View File

@ -58,13 +58,11 @@ namespace CLI {
std::string value; std::string value;
PositionalArgument(); PositionalArgument();
PositionalArgument(std::string description, std::string placeholder); PositionalArgument(std::string placeholder, std::string description);
}; };
class ArgumentsParser { class ArgumentsParser {
bool wrongUsage; private:
std::vector<std::string> wrongUsageMessages;
std::string programName; std::string programName;
std::map<char, Flag*> flagsByShortName; std::map<char, Flag*> flagsByShortName;
std::map<std::string, Flag*> flagsByLongName; std::map<std::string, Flag*> flagsByLongName;
@ -72,6 +70,10 @@ namespace CLI {
std::map<std::string, UnpositionalArgument*> argumentsByLongName; std::map<std::string, UnpositionalArgument*> argumentsByLongName;
std::vector<PositionalArgument> positionalArguments; std::vector<PositionalArgument> positionalArguments;
public:
bool wrongUsage;
std::vector<std::string> wrongUsageMessages;
// using int here bc that's how main() is defined // using int here bc that's how main() is defined
ArgumentsParser(int argc, char* argv[], std::vector<Flag> flags, std::vector<UnpositionalArgument> unpositionalArguments, std::vector<PositionalArgument> positionalArguments); ArgumentsParser(int argc, char* argv[], std::vector<Flag> flags, std::vector<UnpositionalArgument> unpositionalArguments, std::vector<PositionalArgument> positionalArguments);
~ArgumentsParser(); ~ArgumentsParser();

View File

@ -23,6 +23,9 @@
#include "../lib/error.h++" #include "../lib/error.h++"
int main(){ int main(){
std::cout << "################################################################################" << std::endl;
std::cout << "NBT helper tests" << std::endl;
std::cout << "################################################################################" << std::endl;
// used for all integer tests // used for all integer tests
uint8_t dataForIntTest[] = {30, 31, 32, 33, 34, 35, 36, 37, 38, 39}; uint8_t dataForIntTest[] = {30, 31, 32, 33, 34, 35, 36, 37, 38, 39};