Skip to content

Commit

Permalink
Catch unknown arguments and refer to help page (#19)
Browse files Browse the repository at this point in the history
* Fix building without passing build type

* Update utl and cista

* Update fmt

Using fmt::runtime as a workaround there, I wasn't able to figure out
which change caused the compiler to complain about command not being a
constexpr.

* Update boost and zlib

* Catch unknown arguments

* Update doctest
  • Loading branch information
jbruechert authored Mar 8, 2025
1 parent 187773f commit 81b1351
Show file tree
Hide file tree
Showing 11 changed files with 3,977 additions and 2,152 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ target_compile_features(pkglib PUBLIC cxx_std_17)
add_executable(pkg src/main.cc)
target_link_libraries(pkg pkglib)
target_compile_features(pkg PRIVATE cxx_std_17)
if (${CMAKE_BUILD_TYPE} STREQUAL Release AND NOT MSVC)
if ("${CMAKE_BUILD_TYPE}" STREQUAL Release AND NOT MSVC)
add_custom_command(
TARGET pkg
POST_BUILD
Expand Down
2 changes: 1 addition & 1 deletion deps/boost
2 changes: 1 addition & 1 deletion deps/cista
Submodule cista updated 112 files
2 changes: 1 addition & 1 deletion deps/fmt
Submodule fmt updated 247 files
2 changes: 1 addition & 1 deletion deps/utl
Submodule utl updated 119 files
2 changes: 1 addition & 1 deletion deps/zlib
Submodule zlib updated 1 files
+10 −24 CMakeLists.txt
4 changes: 2 additions & 2 deletions include/pkg/dep.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <set>
#include <string>

#include "utl/struct/comparable.h"
#include "cista/reflection/comparable.h"

#include "boost/filesystem/path.hpp"

Expand All @@ -14,7 +14,7 @@ constexpr auto const ROOT = ".";
constexpr auto const PKG_FILE = ".pkg";

struct branch_commit {
MAKE_COMPARABLE()
CISTA_COMPARABLE()
std::string branch_, commit_;
};

Expand Down
6 changes: 3 additions & 3 deletions include/pkg/exec.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ exec_result exec(boost::filesystem::path const& working_directory,

template <typename... Args>
exec_result exec(boost::filesystem::path const& working_directory,
char const* command, Args... args) {
return exec(working_directory, fmt::format(command, args...));
fmt::format_string<Args...> command, Args&&... args) {
return exec(working_directory, fmt::format(fmt::runtime(command), args...));
}

struct executor {
template <typename... Args>
exec_result exec(boost::filesystem::path const& working_directory,
char const* command, Args... args) {
fmt::format_string<Args...> command, Args... args) {
try {
return results_.emplace_back(
::pkg::exec(working_directory, command, std::forward<Args>(args)...));
Expand Down
4 changes: 2 additions & 2 deletions include/pkg/git.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <set>
#include <string>

#include "utl/struct/comparable.h"
#include "cista/reflection/comparable.h"

#include "boost/filesystem/path.hpp"

Expand All @@ -13,7 +13,7 @@
namespace pkg {

struct commit_info {
MAKE_COMPARABLE()
CISTA_COMPARABLE()
std::string info_;
branch_commit bc_;
};
Expand Down
5 changes: 4 additions & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ bool has_flag(int argc, char** argv, char const* str) {
}

int main(int argc, char** argv) {
if (argc < 2) {
if (argc < 2 || has_flag(argc - 1, argv + 1, "--help") ||
has_flag(argc - 1, argv + 1, "-h")) {
printf(
"Usage:\n"
" pkg load | -l [clone dependencies]\n"
Expand All @@ -40,6 +41,8 @@ int main(int argc, char** argv) {
has_flag(argc - 1, argv + 1, "-r"));
} else if (mode == "status" || mode == "-s") {
print_status(fs::path{"."}, fs::path("deps"));
} else {
fmt::print("Unknown mode {}. See pkg --help for usage.", mode);
}
} catch (std::exception const& e) {
std::cerr << "error: " << e.what() << "\n";
Expand Down
6,098 changes: 3,960 additions & 2,138 deletions test/doctest.h

Large diffs are not rendered by default.

0 comments on commit 81b1351

Please sign in to comment.