MCPcopy Create free account
hub / github.com/catboost/catboost / TFreeArgSpec

Class TFreeArgSpec

library/cpp/getopt/small/last_getopt_opt.h:806–947  ·  view source on GitHub ↗

* NLastGetopt::TFreeArgSpec is a storage of data about free argument. * The data is help information and (maybe) linked named argument. * * The help information consists of following: * help string * argument name (title) */

Source from the content-addressed store, hash-verified

804 * argument name (title)
805 */
806 struct TFreeArgSpec {
807 template <ArgTagConcept E>
808 using TTagger = std::function<E(const TString&)>;
809
810 TFreeArgSpec() = default;
811 TFreeArgSpec(const TString& title, const TString& help = TString(), bool optional = false)
812 : Title_(title)
813 , Help_(help)
814 , Optional_(optional)
815 {
816 }
817
818 TString Title_;
819 TString Help_;
820 TString CompletionArgHelp_;
821 TTagger<ui32> Tagger_;
822
823 bool Optional_ = false;
824 NComp::ICompleterPtr Completer_ = nullptr;
825
826 /**
827 * Check if this argument have default values for its title and help.
828 */
829 bool IsDefault() const {
830 return Title_.empty() && Help_.empty();
831 }
832
833 /**
834 * Set argument title.
835 */
836 TFreeArgSpec& Title(TString title) {
837 Title_ = std::move(title);
838 return *this;
839 }
840
841 /**
842 * Get argument title. If title is empty, returns a default one.
843 */
844 TStringBuf GetTitle(TStringBuf defaultTitle) const {
845 return Title_ ? TStringBuf(Title_) : defaultTitle;
846 }
847
848 /**
849 * Set help string that appears with `--help`. Unless `CompletionHelp` is given, this message will also be used
850 * in completion script. In this case, don't make it too long, don't start it with a capital letter and don't
851 * end it with a full stop.
852 *
853 * See `TOpt::Help` function for more on how `Help` and `CompletionArgHelp` differ one from another.
854 */
855 TFreeArgSpec& Help(TString help) {
856 Help_ = std::move(help);
857 return *this;
858 }
859
860 /**
861 * Get help string that appears with `--help`.
862 */
863 TStringBuf GetHelp() const {

Callers 2

SetFreeArgTitleMethod · 0.85
PrintCmdLineMethod · 0.85

Calls 1

moveFunction · 0.50

Tested by

no test coverage detected