feat: finish clap manual namespace
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include "../../patch/stream.hpp"
|
||||
#include "../../patch/format.hpp"
|
||||
#include "../../string/op.hpp"
|
||||
#include "../../rust/env.hpp"
|
||||
#include <ranges>
|
||||
|
||||
#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()) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -4,11 +4,10 @@
|
||||
#include <string_view>
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user