diff --git a/.gitignore b/.gitignore index 835c4bf..32fb374 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ kmers kmerstest kmercamel kmercameltest +src/version.h 🐫 bin/ diff --git a/Makefile b/Makefile index 4e18851..155d194 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ cpptest: kmercameltest converttest: convert_superstring_unittest.py ./convert_superstring_unittest.py -kmercamel: $(SRC)/main.cpp $(SRC)/$(wildcard *.cpp *.h *.hpp) +kmercamel: $(SRC)/main.cpp $(SRC)/$(wildcard *.cpp *.h *.hpp) src/version.h $(CXX) $(CXXFLAGS) $(SRC)/main.cpp -o $@ $(LDFLAGS) cp kmercamel 🐫 || true @@ -32,9 +32,14 @@ kmercameltest: $(SRC)/unittest.cpp gtest-all.o $(SRC)/$(wildcard *.cpp *.h *.hpp gtest-all.o: $(GTEST)/src/gtest-all.cc $(wildcard *.cpp *.h *.hpp) $(CXX) $(CXXFLAGS) -isystem $(GTEST)/include -I $(GTEST)/include -I $(GTEST) -DGTEST_CREATE_SHARED_LIBRARY=1 -c -pthread $(GTEST)/src/gtest-all.cc -o $@ +src/version.h: src/version + ./create-version.sh + + clean: rm -f kmercamel rm -f 🐫 || true rm -f kmercameltest rm -r -f ./bin rm -f gtest-all.o + rm -f src/version.h diff --git a/create-version.sh b/create-version.sh new file mode 100755 index 0000000..1561dd2 --- /dev/null +++ b/create-version.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +cat <(echo "#define VERSION \"") src/version <(echo -) <(git rev-parse HEAD | head -c6) <(echo \") | tr -d '\n' > src/version.h diff --git a/src/main.cpp b/src/main.cpp index d28f15f..e31bc34 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,9 +9,10 @@ #include #include #include "unistd.h" +#include "version.h" void Help() { - std::cerr << "KmerCamel v0.2" << std::endl; + std::cerr << "KmerCamel version " << VERSION << std::endl; std::cerr << "Accepted arguments:" << std::endl; std::cerr << " -p path_to_fasta - required; valid path to fasta file" << std::endl; std::cerr << " -k k_value - required; integer value for k" << std::endl; @@ -20,10 +21,15 @@ void Help() { std::cerr << " -d d_value - integer value for d_max; default 5" << std::endl; std::cerr << " -c - treat k-mer and its reverse complement as equal" << std::endl; std::cerr << " -h - print help" << std::endl; + std::cerr << " -v - print version" << std::endl; std::cerr << "Example usage: ./kmercamel -p path_to_fasta -k 13 -d 5 -a local" << std::endl; std::cerr << "Possible algorithms: global globalAC local localAC streaming" << std::endl; } +void Version() { + std::cerr << VERSION << std::endl; +} + int main(int argc, char **argv) { std::string path; int k = 0; @@ -35,7 +41,7 @@ int main(int argc, char **argv) { bool d_set = false; int opt; try { - while ((opt = getopt(argc, argv, "p:k:d:a:o:hc")) != -1) { + while ((opt = getopt(argc, argv, "p:k:d:a:o:hcv")) != -1) { switch(opt) { case 'p': path = optarg; @@ -62,6 +68,9 @@ int main(int argc, char **argv) { case 'c': complements = true; break; + case 'v': + Version(); + return 0; case 'h': default: Help(); diff --git a/src/version b/src/version new file mode 100644 index 0000000..3b04cfb --- /dev/null +++ b/src/version @@ -0,0 +1 @@ +0.2