diff --git a/flake.nix b/flake.nix index 92eddaa..2804a77 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,7 @@ }; outputs = flakes: let + version = "1.3.0"; self = flakes.self.packages.x86_64-linux; nixpkgs = flakes.nixpkgs.legacyPackages.x86_64-linux.pkgsStatic; nixpkgs-dyn = flakes.nixpkgs.legacyPackages.x86_64-linux; @@ -120,6 +121,7 @@ ${cxx} \ -o $out/bin/knock \ ${./src/knock.cpp} \ + -D KNOCK_VERSION='"${version}"' \ -Wl,--as-needed -static \ ${self.utils-common}/lib/libutils-common.a \ ${self.gourou}/lib/libgourou.a \ diff --git a/src/knock.cpp b/src/knock.cpp index 9c5e9a0..014d50d 100644 --- a/src/knock.cpp +++ b/src/knock.cpp @@ -3,12 +3,26 @@ #include "libgourou_common.h" #include "libgourou.h" +#ifndef KNOCK_VERSION + #error KNOCK_VERSION must be defined +#endif + std::string get_data_dir(); void verify_absence(std::string file); void verify_presence(std::string file); 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) { throw std::invalid_argument("the ACSM file must be passed as an argument"); } diff --git a/tests/tests.py b/tests/tests.py index fd3e710..ef82f8c 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -19,8 +19,14 @@ if len(sys.argv) != 2: sys.exit() 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(): shutil.rmtree(workspace) workspace.mkdir() @@ -50,7 +56,7 @@ for i, link in enumerate(links): result = subprocess.run([knock, file]) if result.returncode != 0: - print("Failed") + print("Test failed: knock failed to convert a file") sys.exit() print("Success\n---")