36 ProgramBase(
const std::string &name = std::string());
43 INLINE
void show_text(
const std::string &text);
44 void show_text(
const std::string &prefix,
int indent_width, std::string text);
57 typedef bool (*OptionDispatchFunction)(
const std::string &opt,
const std::string &parm,
void *data);
58 typedef bool (*OptionDispatchMethod)(
ProgramBase *
self,
const std::string &opt,
const std::string &parm,
void *data);
60 virtual bool handle_args(
Args &args);
61 virtual bool post_command_line();
63 void set_program_brief(
const std::string &brief);
64 void set_program_description(
const std::string &description);
65 void clear_runlines();
66 void add_runline(
const std::string &runline);
68 void add_option(
const std::string &option,
const std::string &parm_name,
69 int index_group,
const std::string &description,
70 OptionDispatchFunction option_function,
71 bool *bool_var =
nullptr,
72 void *option_data =
nullptr);
73 void add_option(
const std::string &option,
const std::string &parm_name,
74 int index_group,
const std::string &description,
75 OptionDispatchMethod option_method,
76 bool *bool_var =
nullptr,
77 void *option_data =
nullptr);
78 bool redescribe_option(
const std::string &option,
const std::string &description);
79 bool remove_option(
const std::string &option);
81 void add_path_replace_options();
82 void add_path_store_options();
84 static bool dispatch_none(
const std::string &opt,
const std::string &arg,
void *);
85 static bool dispatch_true(
const std::string &opt,
const std::string &arg,
void *var);
86 static bool dispatch_false(
const std::string &opt,
const std::string &arg,
void *var);
87 static bool dispatch_count(
const std::string &opt,
const std::string &arg,
void *var);
88 static bool dispatch_int(
const std::string &opt,
const std::string &arg,
void *var);
89 static bool dispatch_int_pair(
const std::string &opt,
const std::string &arg,
void *var);
90 static bool dispatch_int_quad(
const std::string &opt,
const std::string &arg,
void *var);
91 static bool dispatch_double(
const std::string &opt,
const std::string &arg,
void *var);
92 static bool dispatch_double_pair(
const std::string &opt,
const std::string &arg,
void *var);
93 static bool dispatch_double_triple(
const std::string &opt,
const std::string &arg,
void *var);
94 static bool dispatch_double_quad(
const std::string &opt,
const std::string &arg,
void *var);
95 static bool dispatch_color(
const std::string &opt,
const std::string &arg,
void *var);
96 static bool dispatch_string(
const std::string &opt,
const std::string &arg,
void *var);
97 static bool dispatch_vector_string(
const std::string &opt,
const std::string &arg,
void *var);
98 static bool dispatch_vector_string_comma(
const std::string &opt,
const std::string &arg,
void *var);
99 static bool dispatch_filename(
const std::string &opt,
const std::string &arg,
void *var);
100 static bool dispatch_search_path(
const std::string &opt,
const std::string &arg,
void *var);
101 static bool dispatch_coordinate_system(
const std::string &opt,
const std::string &arg,
void *var);
102 static bool dispatch_units(
const std::string &opt,
const std::string &arg,
void *var);
103 static bool dispatch_image_type(
const std::string &opt,
const std::string &arg,
void *var);
104 static bool dispatch_path_replace(
const std::string &opt,
const std::string &arg,
void *var);
105 static bool dispatch_path_store(
const std::string &opt,
const std::string &arg,
void *var);
107 static bool handle_help_option(
const std::string &opt,
const std::string &arg,
void *);
109 static void format_text(std::ostream &out,
bool &last_newline,
110 const std::string &prefix,
int indent_width,
111 const std::string &text,
int line_width);
114 bool _got_path_store;
115 bool _got_path_directory;
120 void get_terminal_width();
125 std::string _parm_name;
128 std::string _description;
129 OptionDispatchFunction _option_function;
130 OptionDispatchMethod _option_method;
135 class SortOptionsByIndex {
137 bool operator () (
const Option *a,
const Option *b)
const;
142 std::string _description;
143 typedef vector_string Runlines;
151 bool _sorted_options;
158 bool _got_terminal_width;
160 bool _got_option_indent;
This is intended to be the base class for most general-purpose utility programs in the PANDATOOL tree...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
void show_usage()
Writes the usage line(s) to stderr.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void show_description()
Writes the program description to stderr.
The name of a file, such as a texture file or an Egg file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::string get_exec_command() const
Returns the command that invoked this program, as a shell-friendly string, suitable for pasting into ...
void show_options()
Describes each of the available options to stderr.
void write_man_page(std::ostream &out)
Generates a man page in nroff syntax based on the description and options.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This encapsulates the user's command-line request to replace existing, incorrect pathnames to models ...
void show_text(const std::string &text)
Formats the indicated text to stderr with the known _terminal_width.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.