added version/help page

This commit is contained in:
Benton Edmondson 2022-06-06 22:19:34 -04:00
parent d26dbc7734
commit e7a8dd9af4
3 changed files with 24 additions and 2 deletions

View file

@ -24,6 +24,7 @@
}; };
outputs = flakes: let outputs = flakes: let
version = "1.3.0";
self = flakes.self.packages.x86_64-linux; self = flakes.self.packages.x86_64-linux;
nixpkgs = flakes.nixpkgs.legacyPackages.x86_64-linux.pkgsStatic; nixpkgs = flakes.nixpkgs.legacyPackages.x86_64-linux.pkgsStatic;
nixpkgs-dyn = flakes.nixpkgs.legacyPackages.x86_64-linux; nixpkgs-dyn = flakes.nixpkgs.legacyPackages.x86_64-linux;
@ -120,6 +121,7 @@
${cxx} \ ${cxx} \
-o $out/bin/knock \ -o $out/bin/knock \
${./src/knock.cpp} \ ${./src/knock.cpp} \
-D KNOCK_VERSION='"${version}"' \
-Wl,--as-needed -static \ -Wl,--as-needed -static \
${self.utils-common}/lib/libutils-common.a \ ${self.utils-common}/lib/libutils-common.a \
${self.gourou}/lib/libgourou.a \ ${self.gourou}/lib/libgourou.a \

View file

@ -3,12 +3,26 @@
#include "libgourou_common.h" #include "libgourou_common.h"
#include "libgourou.h" #include "libgourou.h"
#ifndef KNOCK_VERSION
#error KNOCK_VERSION must be defined
#endif
std::string get_data_dir(); std::string get_data_dir();
void verify_absence(std::string file); void verify_absence(std::string file);
void verify_presence(std::string file); void verify_presence(std::string file);
int main(int argc, char** argv) try { int main(int argc, char** argv) try {
if (argc == 1) {
std::cout
<< "info: knock version " << KNOCK_VERSION << ", libgourou version "
<< LIBGOUROU_VERSION << "\n"
<< "usage: " << argv[0] << " [ACSM]" << "\n"
<< "result: converts file ACSM to a plain EPUB/PDF if present, otherwise prints this"
<< std::endl;
return EXIT_SUCCESS;
}
if (argc != 2) { if (argc != 2) {
throw std::invalid_argument("the ACSM file must be passed as an argument"); throw std::invalid_argument("the ACSM file must be passed as an argument");
} }

View file

@ -19,8 +19,14 @@ if len(sys.argv) != 2:
sys.exit() sys.exit()
print("Testing " + str(knock)) print("Testing " + str(knock))
workspace = Path(sys.argv[1])
result = subprocess.run(knock)
if result.returncode != 0:
print("Test failed: knock failed to describe itself")
sys.exit()
print("---")
workspace = Path(sys.argv[1])
if workspace.exists(): if workspace.exists():
shutil.rmtree(workspace) shutil.rmtree(workspace)
workspace.mkdir() workspace.mkdir()
@ -50,7 +56,7 @@ for i, link in enumerate(links):
result = subprocess.run([knock, file]) result = subprocess.run([knock, file])
if result.returncode != 0: if result.returncode != 0:
print("Failed") print("Test failed: knock failed to convert a file")
sys.exit() sys.exit()
print("Success\n---") print("Success\n---")