Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch unknown arguments and refer to help page #19

Merged
merged 6 commits into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading