diff --git a/src/yycc/carton/clap/manual.cpp b/src/yycc/carton/clap/manual.cpp index be4f539..8e7eff2 100644 --- a/src/yycc/carton/clap/manual.cpp +++ b/src/yycc/carton/clap/manual.cpp @@ -3,6 +3,7 @@ #include "../../patch/stream.hpp" #include "../../patch/format.hpp" #include "../../string/op.hpp" +#include "../../rust/env.hpp" #include #define CLAP ::yycc::carton::clap @@ -10,6 +11,7 @@ #define TERMCOLOR ::yycc::carton::termcolor #define OP ::yycc::string::op #define FORMAT ::yycc::patch::format +#define ENV ::yycc::rust::env using namespace ::yycc::patch::stream; @@ -107,8 +109,12 @@ namespace yycc::carton::clap::manual { void Manual::print_help(std::ostream &dst) const { this->print_version(); - TERMCOLOR::cprintln(trctx.usage_title, TERMCOLOR::Color::Yellow, TERMCOLOR::Color::Default, TERMCOLOR::Attribute::Default, dst); - dst << INDENT << FORMAT::format(trctx.usage_body, app.get_summary().get_bin_name()) << std::endl; + // only print usage if we can fetch the name of executable + auto executable = ENV::current_exe(); + if (executable.has_value()) { + TERMCOLOR::cprintln(trctx.usage_title, TERMCOLOR::Color::Yellow, TERMCOLOR::Color::Default, TERMCOLOR::Attribute::Default, dst); + dst << INDENT << FORMAT::format(trctx.usage_body, executable.value()) << std::endl; + } const auto &variables = app.get_variables(); if (!variables.empty()) { diff --git a/src/yycc/carton/clap/summary.cpp b/src/yycc/carton/clap/summary.cpp index 5365a1a..69d9567 100644 --- a/src/yycc/carton/clap/summary.cpp +++ b/src/yycc/carton/clap/summary.cpp @@ -3,11 +3,9 @@ namespace yycc::carton::clap::summary { Summary::Summary(const std::u8string_view &name, - const std::u8string_view &bin_name, const std::u8string_view &author, const std::u8string_view &version, - const std::u8string_view &description) : - name(name), bin_name(bin_name), author(author), version(version), description(description) {} + const std::u8string_view &description) : name(name), author(author), version(version), description(description) {} Summary::~Summary() {} @@ -15,10 +13,6 @@ namespace yycc::carton::clap::summary { return this->name; } - std::u8string_view Summary::get_bin_name() const { - return this->bin_name; - } - std::u8string_view Summary::get_author() const { return this->author; } diff --git a/src/yycc/carton/clap/summary.hpp b/src/yycc/carton/clap/summary.hpp index 6bfdc29..2098d9d 100644 --- a/src/yycc/carton/clap/summary.hpp +++ b/src/yycc/carton/clap/summary.hpp @@ -4,11 +4,10 @@ #include namespace yycc::carton::clap::summary { - + class Summary { public: Summary(const std::u8string_view& name, - const std::u8string_view& bin_name, const std::u8string_view& author, const std::u8string_view& version, const std::u8string_view& description); @@ -17,13 +16,12 @@ namespace yycc::carton::clap::summary { public: std::u8string_view get_name() const; - std::u8string_view get_bin_name() const; std::u8string_view get_author() const; std::u8string_view get_version() const; std::u8string_view get_description() const; private: - std::u8string name, bin_name, author, version, description; + std::u8string name, author, version, description; }; -} +} // namespace yycc::carton::clap::summary