mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-17 16:31:27 -04:00
refactor: split out dwarfs_tool library
This commit is contained in:
parent
4d879378dd
commit
b0575d6a0c
@ -618,6 +618,7 @@ list(APPEND LIBDWARFS_COMMON_SRC
|
||||
src/dwarfs/internal/string_table.cpp
|
||||
src/dwarfs/internal/wcwidth.c
|
||||
src/dwarfs/internal/worker_group.cpp
|
||||
src/dwarfs/iolayer.cpp
|
||||
src/dwarfs/library_dependencies.cpp
|
||||
src/dwarfs/logger.cpp
|
||||
src/dwarfs/mmap.cpp
|
||||
@ -683,9 +684,8 @@ list(APPEND LIBDWARFS_EXTRACTOR_SRC
|
||||
)
|
||||
|
||||
list(APPEND LIBDWARFS_TOOL_SRC
|
||||
src/dwarfs/iolayer.cpp
|
||||
src/dwarfs/safe_main.cpp
|
||||
src/dwarfs/tool.cpp
|
||||
src/dwarfs/tool/safe_main.cpp
|
||||
src/dwarfs/tool/tool.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
@ -696,12 +696,13 @@ endif()
|
||||
|
||||
if(WITH_MAN_OPTION)
|
||||
list(APPEND LIBDWARFS_TOOL_SRC
|
||||
src/dwarfs/pager.cpp
|
||||
src/dwarfs/render_manpage.cpp
|
||||
src/dwarfs/tool/pager.cpp
|
||||
src/dwarfs/tool/render_manpage.cpp
|
||||
)
|
||||
|
||||
if(DWARFS_GIT_BUILD)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/render_manpage.cmake)
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/src/dwarfs/tool")
|
||||
set(DWARFS_MANPAGE_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
else()
|
||||
set(DWARFS_MANPAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@ -711,10 +712,10 @@ if(WITH_MAN_OPTION)
|
||||
if(DWARFS_GIT_BUILD)
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/src/dwarfs")
|
||||
add_manpage_source(doc/${man}.md NAME ${man}
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/dwarfs/${man}_manpage.cpp)
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/dwarfs/tool/${man}_manpage.cpp)
|
||||
endif()
|
||||
|
||||
list(APPEND LIBDWARFS_TOOL_SRC ${DWARFS_MANPAGE_SOURCE_DIR}/src/dwarfs/${man}_manpage.cpp)
|
||||
list(APPEND LIBDWARFS_TOOL_SRC ${DWARFS_MANPAGE_SOURCE_DIR}/src/dwarfs/tool/${man}_manpage.cpp)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
@ -1398,6 +1399,7 @@ if(NOT STATIC_BUILD_DO_NOT_USE)
|
||||
DIRECTORY include/dwarfs
|
||||
DESTINATION include
|
||||
PATTERN include/dwarfs/internal EXCLUDE
|
||||
PATTERN include/dwarfs/tool EXCLUDE
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -21,7 +21,7 @@ if(CPACK_SOURCE_INSTALLED_DIRECTORIES)
|
||||
file(INSTALL "@PROJECT_BINARY_DIR@/include/dwarfs/version.h" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/include/dwarfs")
|
||||
file(INSTALL "@PROJECT_BINARY_DIR@/src/dwarfs/version.cpp" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/src/dwarfs")
|
||||
foreach(prog dwarfs dwarfsck dwarfsextract mkdwarfs)
|
||||
file(INSTALL "@PROJECT_BINARY_DIR@/src/dwarfs/${prog}_manpage.cpp" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/src/dwarfs")
|
||||
file(INSTALL "@PROJECT_BINARY_DIR@/src/dwarfs/tool/${prog}_manpage.cpp" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/src/dwarfs/tool")
|
||||
endforeach()
|
||||
file(INSTALL "@PROJECT_BINARY_DIR@/package_version.cmake" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/cmake")
|
||||
message(STATUS "Adding generated thrift files from @PROJECT_BINARY_DIR@ to ${CMAKE_CURRENT_BINARY_DIR}...")
|
||||
|
@ -289,9 +289,9 @@ class ManpageRenderer(mistletoe.base_renderer.BaseRenderer):
|
||||
|
||||
def render_document(self, token):
|
||||
rv = """#include <array>
|
||||
#include "dwarfs/manpage.h"
|
||||
#include <dwarfs/tool/manpage.h>
|
||||
|
||||
namespace dwarfs::manpage {
|
||||
namespace dwarfs::tool::manpage {
|
||||
|
||||
namespace {
|
||||
"""
|
||||
@ -312,7 +312,7 @@ namespace {
|
||||
|
||||
document get_{self.__document_name}_manpage() {{ return document_array; }}
|
||||
|
||||
}} // namespace dwarfs::manpage
|
||||
}} // namespace dwarfs::tool::manpage
|
||||
"""
|
||||
return rv
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <fmt/color.h>
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace dwarfs::manpage {
|
||||
namespace dwarfs::tool::manpage {
|
||||
|
||||
struct element {
|
||||
fmt::text_style style;
|
||||
@ -48,4 +48,4 @@ document get_dwarfs_manpage();
|
||||
document get_dwarfsck_manpage();
|
||||
document get_dwarfsextract_manpage();
|
||||
|
||||
} // namespace dwarfs::manpage
|
||||
} // namespace dwarfs::tool::manpage
|
@ -30,6 +30,8 @@ namespace dwarfs {
|
||||
|
||||
class os_access;
|
||||
|
||||
namespace tool {
|
||||
|
||||
struct pager_program {
|
||||
std::filesystem::path name;
|
||||
std::vector<std::string> args;
|
||||
@ -38,4 +40,6 @@ struct pager_program {
|
||||
std::optional<pager_program> find_pager_program(os_access const& os);
|
||||
void show_in_pager(pager_program const& pager, std::string text);
|
||||
|
||||
} // namespace tool
|
||||
|
||||
} // namespace dwarfs
|
@ -23,10 +23,10 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <dwarfs/manpage.h>
|
||||
#include <dwarfs/tool/manpage.h>
|
||||
|
||||
namespace dwarfs {
|
||||
namespace dwarfs::tool {
|
||||
|
||||
std::string render_manpage(manpage::document doc, size_t width, bool color);
|
||||
|
||||
} // namespace dwarfs
|
||||
} // namespace dwarfs::tool
|
@ -23,8 +23,8 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace dwarfs {
|
||||
namespace dwarfs::tool {
|
||||
|
||||
int safe_main(std::function<int(void)> fn);
|
||||
|
||||
} // namespace dwarfs
|
||||
} // namespace dwarfs::tool
|
@ -27,7 +27,7 @@
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#ifdef DWARFS_BUILTIN_MANPAGE
|
||||
#include <dwarfs/manpage.h>
|
||||
#include <dwarfs/tool/manpage.h>
|
||||
#endif
|
||||
|
||||
namespace dwarfs {
|
||||
@ -35,6 +35,8 @@ namespace dwarfs {
|
||||
struct logger_options;
|
||||
struct iolayer;
|
||||
|
||||
namespace tool {
|
||||
|
||||
std::string
|
||||
tool_header(std::string_view tool_name, std::string_view extra_info = "");
|
||||
|
||||
@ -45,4 +47,6 @@ void add_common_options(boost::program_options::options_description& opts,
|
||||
void show_manpage(manpage::document doc, iolayer const& iol);
|
||||
#endif
|
||||
|
||||
} // namespace tool
|
||||
|
||||
} // namespace dwarfs
|
@ -19,9 +19,10 @@
|
||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dwarfs/safe_main.h>
|
||||
#include <dwarfs/tool/safe_main.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
|
||||
int SYS_MAIN(int argc, dwarfs::sys_char** argv) {
|
||||
return dwarfs::safe_main([&] { return dwarfs::dwarfs_main(argc, argv); });
|
||||
return dwarfs::tool::safe_main(
|
||||
[&] { return dwarfs::dwarfs_main(argc, argv); });
|
||||
}
|
||||
|
@ -29,9 +29,9 @@
|
||||
#include <folly/portability/Unistd.h>
|
||||
|
||||
#include <dwarfs/os_access.h>
|
||||
#include <dwarfs/pager.h>
|
||||
#include <dwarfs/tool/pager.h>
|
||||
|
||||
namespace dwarfs {
|
||||
namespace dwarfs::tool {
|
||||
|
||||
namespace {
|
||||
|
||||
@ -86,4 +86,4 @@ void show_in_pager(pager_program const& pager, std::string text) {
|
||||
proc.wait();
|
||||
}
|
||||
|
||||
} // namespace dwarfs
|
||||
} // namespace dwarfs::tool
|
@ -21,9 +21,9 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <dwarfs/render_manpage.h>
|
||||
#include <dwarfs/tool/render_manpage.h>
|
||||
|
||||
namespace dwarfs {
|
||||
namespace dwarfs::tool {
|
||||
|
||||
std::string render_manpage(manpage::document const doc, size_t const width,
|
||||
bool const color) {
|
||||
@ -84,4 +84,4 @@ std::string render_manpage(manpage::document const doc, size_t const width,
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace dwarfs
|
||||
} // namespace dwarfs::tool
|
@ -26,11 +26,11 @@
|
||||
#include <folly/experimental/symbolizer/SignalHandler.h>
|
||||
|
||||
#include <dwarfs/error.h>
|
||||
#include <dwarfs/safe_main.h>
|
||||
#include <dwarfs/terminal.h>
|
||||
#include <dwarfs/tool/safe_main.h>
|
||||
#include <dwarfs/util.h>
|
||||
|
||||
namespace dwarfs {
|
||||
namespace dwarfs::tool {
|
||||
|
||||
int safe_main(std::function<int(void)> fn) {
|
||||
try {
|
||||
@ -48,4 +48,4 @@ int safe_main(std::function<int(void)> fn) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace dwarfs
|
||||
} // namespace dwarfs::tool
|
@ -24,14 +24,14 @@
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <dwarfs/logger.h>
|
||||
#include <dwarfs/tool.h>
|
||||
#include <dwarfs/tool/tool.h>
|
||||
#include <dwarfs/version.h>
|
||||
|
||||
#ifdef DWARFS_BUILTIN_MANPAGE
|
||||
#include <dwarfs/iolayer.h>
|
||||
#include <dwarfs/pager.h>
|
||||
#include <dwarfs/render_manpage.h>
|
||||
#include <dwarfs/terminal.h>
|
||||
#include <dwarfs/tool/pager.h>
|
||||
#include <dwarfs/tool/render_manpage.h>
|
||||
#endif
|
||||
|
||||
namespace po = boost::program_options;
|
||||
@ -46,7 +46,7 @@ void validate(boost::any& v, const std::vector<std::string>&,
|
||||
|
||||
} // namespace boost
|
||||
|
||||
namespace dwarfs {
|
||||
namespace dwarfs::tool {
|
||||
|
||||
std::string
|
||||
tool_header(std::string_view tool_name, std::string_view extra_info) {
|
||||
@ -106,4 +106,4 @@ void show_manpage(manpage::document doc, iolayer const& iol) {
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace dwarfs
|
||||
} // namespace dwarfs::tool
|
@ -97,7 +97,7 @@
|
||||
#include <dwarfs/performance_monitor.h>
|
||||
#include <dwarfs/scope_exit.h>
|
||||
#include <dwarfs/string.h>
|
||||
#include <dwarfs/tool.h>
|
||||
#include <dwarfs/tool/tool.h>
|
||||
#include <dwarfs/util.h>
|
||||
#include <dwarfs/version.h>
|
||||
#include <dwarfs/vfs_stat.h>
|
||||
@ -1165,8 +1165,8 @@ int op_rename(char const* from, char const* to, unsigned int flags) {
|
||||
#endif
|
||||
|
||||
void usage(std::ostream& os, std::filesystem::path const& progname) {
|
||||
os << tool_header("dwarfs",
|
||||
fmt::format(", fuse version {}", FUSE_USE_VERSION))
|
||||
os << tool::tool_header("dwarfs",
|
||||
fmt::format(", fuse version {}", FUSE_USE_VERSION))
|
||||
<< library_dependencies::common_as_string() << "\n\n"
|
||||
#if !DWARFS_FUSE_LOWLEVEL
|
||||
<< "USING HIGH-LEVEL FUSE API\n\n"
|
||||
@ -1504,7 +1504,7 @@ int dwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
if (fuse_parse_cmdline(&args, &fuse_opts) == -1 || !fuse_opts.mountpoint) {
|
||||
#ifdef DWARFS_BUILTIN_MANPAGE
|
||||
if (userdata.opts.is_man) {
|
||||
show_manpage(manpage::get_dwarfs_manpage(), iol);
|
||||
tool::show_manpage(tool::manpage::get_dwarfs_manpage(), iol);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -1524,7 +1524,7 @@ int dwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
if (fuse_parse_cmdline(&args, &mountpoint, &mt, &fg) == -1 || !mountpoint) {
|
||||
#ifdef DWARFS_BUILTIN_MANPAGE
|
||||
if (userdata.opts.is_man) {
|
||||
show_manpage(manpage::get_dwarfs_manpage(), iol);
|
||||
tool::show_manpage(tool::manpage::get_dwarfs_manpage(), iol);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -1609,7 +1609,7 @@ int dwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
|
||||
#ifdef DWARFS_BUILTIN_MANPAGE
|
||||
if (userdata.opts.is_man) {
|
||||
show_manpage(manpage::get_dwarfs_manpage(), iol);
|
||||
tool::show_manpage(tool::manpage::get_dwarfs_manpage(), iol);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -19,10 +19,10 @@
|
||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dwarfs/safe_main.h>
|
||||
#include <dwarfs/tool/safe_main.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
|
||||
int SYS_MAIN(int argc, dwarfs::sys_char** argv) {
|
||||
return dwarfs::safe_main(
|
||||
return dwarfs::tool::safe_main(
|
||||
[&] { return dwarfs::dwarfsbench_main(argc, argv); });
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <dwarfs/mmap.h>
|
||||
#include <dwarfs/options.h>
|
||||
#include <dwarfs/thread_pool.h>
|
||||
#include <dwarfs/tool.h>
|
||||
#include <dwarfs/tool/tool.h>
|
||||
#include <dwarfs/util.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
|
||||
@ -71,7 +71,7 @@ int dwarfsbench_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
;
|
||||
// clang-format on
|
||||
|
||||
add_common_options(opts, logopts);
|
||||
tool::add_common_options(opts, logopts);
|
||||
|
||||
po::variables_map vm;
|
||||
|
||||
@ -84,7 +84,7 @@ int dwarfsbench_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
}
|
||||
|
||||
if (vm.count("help") or !vm.count("filesystem")) {
|
||||
iol.out << tool_header("dwarfsbench")
|
||||
iol.out << tool::tool_header("dwarfsbench")
|
||||
<< library_dependencies::common_as_string() << "\n\n"
|
||||
<< opts << "\n";
|
||||
return 0;
|
||||
|
@ -19,9 +19,10 @@
|
||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dwarfs/safe_main.h>
|
||||
#include <dwarfs/tool/safe_main.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
|
||||
int SYS_MAIN(int argc, dwarfs::sys_char** argv) {
|
||||
return dwarfs::safe_main([&] { return dwarfs::dwarfsck_main(argc, argv); });
|
||||
return dwarfs::tool::safe_main(
|
||||
[&] { return dwarfs::dwarfsck_main(argc, argv); });
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include <dwarfs/os_access.h>
|
||||
#include <dwarfs/program_options_helpers.h>
|
||||
#include <dwarfs/thread_pool.h>
|
||||
#include <dwarfs/tool.h>
|
||||
#include <dwarfs/tool/tool.h>
|
||||
#include <dwarfs/util.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
|
||||
@ -223,7 +223,7 @@ int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
;
|
||||
// clang-format on
|
||||
|
||||
add_common_options(opts, logopts);
|
||||
tool::add_common_options(opts, logopts);
|
||||
|
||||
po::positional_options_description pos;
|
||||
pos.add("input", -1);
|
||||
@ -244,7 +244,7 @@ int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
|
||||
#ifdef DWARFS_BUILTIN_MANPAGE
|
||||
if (vm.count("man")) {
|
||||
show_manpage(manpage::get_dwarfsck_manpage(), iol);
|
||||
tool::show_manpage(tool::manpage::get_dwarfsck_manpage(), iol);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -252,7 +252,7 @@ int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
auto constexpr usage = "Usage: dwarfsck [OPTIONS...]\n";
|
||||
|
||||
if (vm.count("help") or !vm.count("input")) {
|
||||
iol.out << tool_header("dwarfsck")
|
||||
iol.out << tool::tool_header("dwarfsck")
|
||||
<< library_dependencies::common_as_string() << "\n\n"
|
||||
<< usage << "\n"
|
||||
<< opts << "\n";
|
||||
|
@ -19,10 +19,10 @@
|
||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dwarfs/safe_main.h>
|
||||
#include <dwarfs/tool/safe_main.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
|
||||
int SYS_MAIN(int argc, dwarfs::sys_char** argv) {
|
||||
return dwarfs::safe_main(
|
||||
return dwarfs::tool::safe_main(
|
||||
[&] { return dwarfs::dwarfsextract_main(argc, argv); });
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <dwarfs/performance_monitor.h>
|
||||
#include <dwarfs/program_options_helpers.h>
|
||||
#include <dwarfs/string.h>
|
||||
#include <dwarfs/tool.h>
|
||||
#include <dwarfs/tool/tool.h>
|
||||
#include <dwarfs/util.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
|
||||
@ -107,7 +107,7 @@ int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
;
|
||||
// clang-format on
|
||||
|
||||
add_common_options(opts, logopts);
|
||||
tool::add_common_options(opts, logopts);
|
||||
|
||||
po::variables_map vm;
|
||||
|
||||
@ -121,7 +121,7 @@ int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
|
||||
#ifdef DWARFS_BUILTIN_MANPAGE
|
||||
if (vm.count("man")) {
|
||||
show_manpage(manpage::get_dwarfsextract_manpage(), iol);
|
||||
tool::show_manpage(tool::manpage::get_dwarfsextract_manpage(), iol);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -133,7 +133,7 @@ int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
deps.add_common_libraries();
|
||||
filesystem_extractor::add_library_dependencies(deps);
|
||||
|
||||
iol.out << tool_header("dwarfsextract") << deps.as_string() << "\n\n"
|
||||
iol.out << tool::tool_header("dwarfsextract") << deps.as_string() << "\n\n"
|
||||
<< usage << "\n"
|
||||
<< opts << "\n";
|
||||
return 0;
|
||||
|
@ -19,9 +19,10 @@
|
||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dwarfs/safe_main.h>
|
||||
#include <dwarfs/tool/safe_main.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
|
||||
int SYS_MAIN(int argc, dwarfs::sys_char** argv) {
|
||||
return dwarfs::safe_main([&] { return dwarfs::mkdwarfs_main(argc, argv); });
|
||||
return dwarfs::tool::safe_main(
|
||||
[&] { return dwarfs::mkdwarfs_main(argc, argv); });
|
||||
}
|
||||
|
@ -84,7 +84,7 @@
|
||||
#include <dwarfs/string.h>
|
||||
#include <dwarfs/terminal.h>
|
||||
#include <dwarfs/thread_pool.h>
|
||||
#include <dwarfs/tool.h>
|
||||
#include <dwarfs/tool/tool.h>
|
||||
#include <dwarfs/util.h>
|
||||
#include <dwarfs/writer_progress.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
@ -461,7 +461,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
po::value<unsigned>(&level)->default_value(default_level),
|
||||
"compression level (0=fast, 9=best, please see man page for details)")
|
||||
;
|
||||
add_common_options(basic_opts, logopts);
|
||||
tool::add_common_options(basic_opts, logopts);
|
||||
basic_opts.add_options()
|
||||
("long-help,H",
|
||||
"output full help message and exit")
|
||||
@ -679,7 +679,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
|
||||
#ifdef DWARFS_BUILTIN_MANPAGE
|
||||
if (vm.count("man")) {
|
||||
show_manpage(manpage::get_mkdwarfs_manpage(), iol);
|
||||
tool::show_manpage(tool::manpage::get_mkdwarfs_manpage(), iol);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -701,7 +701,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
|
||||
std::string sep(30 + l_dc + l_sc + l_mc + l_or, '-');
|
||||
|
||||
iol.out << tool_header("mkdwarfs")
|
||||
iol.out << tool::tool_header("mkdwarfs")
|
||||
<< library_dependencies::common_as_string() << "\n\n"
|
||||
<< usage << opts << "\n"
|
||||
<< "Compression level defaults:\n"
|
||||
@ -754,7 +754,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
|
||||
if (vm.count("help") or !(vm.count("input") or vm.count("input-list")) or
|
||||
(!vm.count("output") and !vm.count("debug-filter"))) {
|
||||
iol.out << tool_header("mkdwarfs")
|
||||
iol.out << tool::tool_header("mkdwarfs")
|
||||
<< library_dependencies::common_as_string() << "\n\n"
|
||||
<< usage << "\n"
|
||||
<< basic_opts << "\n";
|
||||
|
@ -33,8 +33,8 @@
|
||||
#include <range/v3/view/join.hpp>
|
||||
#include <range/v3/view/map.hpp>
|
||||
|
||||
#include <dwarfs/safe_main.h>
|
||||
#include <dwarfs/tool.h>
|
||||
#include <dwarfs/tool/safe_main.h>
|
||||
#include <dwarfs/tool/tool.h>
|
||||
#include <dwarfs/util.h>
|
||||
#include <dwarfs_tool_main.h>
|
||||
|
||||
@ -64,8 +64,9 @@ int SYS_MAIN(int argc, sys_char** argv) {
|
||||
// first, see if we are called as a copy/hardlink/symlink
|
||||
|
||||
if (auto ext = path.extension().string(); ext.empty() || ext == EXE_EXT) {
|
||||
if (auto it = functions.find(path.stem().string()); it != functions.end()) {
|
||||
return safe_main([&] { return it->second(argc, argv); });
|
||||
auto stem = path.stem().string();
|
||||
if (auto it = functions.find(stem); it != functions.end()) {
|
||||
return tool::safe_main([&] { return it->second(argc, argv); });
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +80,7 @@ int SYS_MAIN(int argc, sys_char** argv) {
|
||||
argv_copy.reserve(argc - 1);
|
||||
argv_copy.emplace_back(argv[0]);
|
||||
std::copy(argv + 2, argv + argc, std::back_inserter(argv_copy));
|
||||
return safe_main(
|
||||
return tool::safe_main(
|
||||
[&] { return it->second(argc - 1, argv_copy.data()); });
|
||||
}
|
||||
}
|
||||
@ -91,7 +92,7 @@ int SYS_MAIN(int argc, sys_char** argv) {
|
||||
ranges::to<std::string>;
|
||||
|
||||
// clang-format off
|
||||
std::cout << tool_header("dwarfs-universal")
|
||||
std::cout << tool::tool_header("dwarfs-universal")
|
||||
<< "Command line options:\n"
|
||||
<< " --tool=<name> "
|
||||
"which tool to run; available tools are:\n"
|
||||
|
@ -25,12 +25,13 @@
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <dwarfs/pager.h>
|
||||
#include <dwarfs/render_manpage.h>
|
||||
#include <dwarfs/tool/pager.h>
|
||||
#include <dwarfs/tool/render_manpage.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
using namespace dwarfs;
|
||||
using namespace dwarfs::tool;
|
||||
|
||||
namespace {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user