Skip to content

Commit 81b1351

Browse files
authored
Catch unknown arguments and refer to help page (#19)
* 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
1 parent 187773f commit 81b1351

File tree

11 files changed

+3977
-2152
lines changed

11 files changed

+3977
-2152
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ target_compile_features(pkglib PUBLIC cxx_std_17)
3333
add_executable(pkg src/main.cc)
3434
target_link_libraries(pkg pkglib)
3535
target_compile_features(pkg PRIVATE cxx_std_17)
36-
if (${CMAKE_BUILD_TYPE} STREQUAL Release AND NOT MSVC)
36+
if ("${CMAKE_BUILD_TYPE}" STREQUAL Release AND NOT MSVC)
3737
add_custom_command(
3838
TARGET pkg
3939
POST_BUILD

deps/boost

deps/cista

Submodule cista updated 112 files

deps/fmt

Submodule fmt updated 247 files

deps/utl

Submodule utl updated 119 files

deps/zlib

include/pkg/dep.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <set>
55
#include <string>
66

7-
#include "utl/struct/comparable.h"
7+
#include "cista/reflection/comparable.h"
88

99
#include "boost/filesystem/path.hpp"
1010

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

1616
struct branch_commit {
17-
MAKE_COMPARABLE()
17+
CISTA_COMPARABLE()
1818
std::string branch_, commit_;
1919
};
2020

include/pkg/exec.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ exec_result exec(boost::filesystem::path const& working_directory,
2828

2929
template <typename... Args>
3030
exec_result exec(boost::filesystem::path const& working_directory,
31-
char const* command, Args... args) {
32-
return exec(working_directory, fmt::format(command, args...));
31+
fmt::format_string<Args...> command, Args&&... args) {
32+
return exec(working_directory, fmt::format(fmt::runtime(command), args...));
3333
}
3434

3535
struct executor {
3636
template <typename... Args>
3737
exec_result exec(boost::filesystem::path const& working_directory,
38-
char const* command, Args... args) {
38+
fmt::format_string<Args...> command, Args... args) {
3939
try {
4040
return results_.emplace_back(
4141
::pkg::exec(working_directory, command, std::forward<Args>(args)...));

include/pkg/git.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <set>
44
#include <string>
55

6-
#include "utl/struct/comparable.h"
6+
#include "cista/reflection/comparable.h"
77

88
#include "boost/filesystem/path.hpp"
99

@@ -13,7 +13,7 @@
1313
namespace pkg {
1414

1515
struct commit_info {
16-
MAKE_COMPARABLE()
16+
CISTA_COMPARABLE()
1717
std::string info_;
1818
branch_commit bc_;
1919
};

src/main.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ bool has_flag(int argc, char** argv, char const* str) {
1616
}
1717

1818
int main(int argc, char** argv) {
19-
if (argc < 2) {
19+
if (argc < 2 || has_flag(argc - 1, argv + 1, "--help") ||
20+
has_flag(argc - 1, argv + 1, "-h")) {
2021
printf(
2122
"Usage:\n"
2223
" pkg load | -l [clone dependencies]\n"
@@ -40,6 +41,8 @@ int main(int argc, char** argv) {
4041
has_flag(argc - 1, argv + 1, "-r"));
4142
} else if (mode == "status" || mode == "-s") {
4243
print_status(fs::path{"."}, fs::path("deps"));
44+
} else {
45+
fmt::print("Unknown mode {}. See pkg --help for usage.", mode);
4346
}
4447
} catch (std::exception const& e) {
4548
std::cerr << "error: " << e.what() << "\n";

0 commit comments

Comments
 (0)