mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Merge pull request #72 from CrustyAuklet/text-pre-post
Add the option to add text before and after help output
This commit is contained in:
commit
f01beb872e
@ -800,6 +800,14 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_description(std::string aDescription) {
|
||||||
|
mDescription = std::move(aDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_epilog(std::string aEpilog) {
|
||||||
|
mEpilog = std::move(aEpilog);
|
||||||
|
}
|
||||||
|
|
||||||
/* Call parse_args_internal - which does all the work
|
/* Call parse_args_internal - which does all the work
|
||||||
* Then, validate the parsed arguments
|
* Then, validate the parsed arguments
|
||||||
* This variant is used mainly for testing
|
* This variant is used mainly for testing
|
||||||
@ -864,6 +872,9 @@ public:
|
|||||||
}
|
}
|
||||||
stream << "\n\n";
|
stream << "\n\n";
|
||||||
|
|
||||||
|
if(!parser.mDescription.empty())
|
||||||
|
stream << parser.mDescription << "\n\n";
|
||||||
|
|
||||||
if (!parser.mPositionalArguments.empty())
|
if (!parser.mPositionalArguments.empty())
|
||||||
stream << "Positional arguments:\n";
|
stream << "Positional arguments:\n";
|
||||||
|
|
||||||
@ -880,6 +891,9 @@ public:
|
|||||||
stream.width(tLongestArgumentLength);
|
stream.width(tLongestArgumentLength);
|
||||||
stream << mOptionalArgument;
|
stream << mOptionalArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!parser.mEpilog.empty())
|
||||||
|
stream << parser.mEpilog << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
@ -988,6 +1002,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string mProgramName;
|
std::string mProgramName;
|
||||||
|
std::string mDescription;
|
||||||
|
std::string mEpilog;
|
||||||
std::list<Argument> mPositionalArguments;
|
std::list<Argument> mPositionalArguments;
|
||||||
std::list<Argument> mOptionalArguments;
|
std::list<Argument> mOptionalArguments;
|
||||||
std::map<std::string_view, list_iterator, std::less<>> mArgumentMap;
|
std::map<std::string_view, list_iterator, std::less<>> mArgumentMap;
|
||||||
|
Loading…
Reference in New Issue
Block a user