MythTV  master
mythutil/commandlineparser.cpp
Go to the documentation of this file.
1 // libmyth* headers
2 #include "mythcorecontext.h"
3 
4 // local headers
5 #include "commandlineparser.h"
6 
10 
12 {
13  QStringList ChanidStartimeVideo;
14  ChanidStartimeVideo << "chanid" << "starttime" << "video";
15  CommandLineArg::AllowOneOf( QList<CommandLineArg*>()
16  // fileutils.cpp
17  << add("--copyfile", "copyfile", false,
18  "Copy a MythTV Storage Group file using RingBuffers", "")
19  ->SetGroup("File")
20  ->SetRequiredChild(QStringList("infile") << "outfile")
21  << add("--download", "download", false,
22  "Download a file using MythDownloadManager", "")
23  ->SetGroup("File")
24  ->SetRequiredChild(QStringList("infile") << "outfile")
25 
26  // mpegutils.cpp
27  << add("--pidcounter", "pidcounter", false,
28  "Count pids in a MythTV Storage Group file", "")
29  ->SetGroup("MPEG-TS")
30  ->SetRequiredChild("infile")
31  << add("--pidfilter", "pidfilter", false,
32  "Filter pids in a MythTV Storage Group file", "")
33  ->SetGroup("MPEG-TS")
34  ->SetRequiredChild(QStringList("infile") << "outfile")
35  << add("--pidprinter", "pidprinter", false,
36  "Print PSIP pids in a MythTV Storage Group file", "")
37  ->SetGroup("MPEG-TS")
38  ->SetRequiredChild("infile")
39  ->SetChild("outfile")
40 
41  // markuputils.cpp
42  << add("--gencutlist", "gencutlist", false,
43  "Copy the commercial skip list to the cutlist.", "")
44  ->SetGroup("Recording Markup")
45  ->SetParentOf(ChanidStartimeVideo)
46  << add("--getcutlist", "getcutlist", false,
47  "Display the current cutlist.", "")
48  ->SetGroup("Recording Markup")
49  ->SetParentOf(ChanidStartimeVideo)
50  << add("--setcutlist", "setcutlist", "",
51  "Set a new cutlist in the form:\n"
52  "#-#[,#-#]... (ie, 1-100,1520-3012,4091-5094)", "")
53  ->SetGroup("Recording Markup")
54  ->SetParentOf(ChanidStartimeVideo)
55  << add("--clearcutlist", "clearcutlist", false,
56  "Clear the cutlist.", "")
57  ->SetGroup("Recording Markup")
58  ->SetParentOf(ChanidStartimeVideo)
59  << add("--getskiplist", "getskiplist", false,
60  "Display the current commercial skip list.", "")
61  ->SetGroup("Recording Markup")
62  ->SetParentOf(ChanidStartimeVideo)
63  << add("--setskiplist", "setskiplist", "",
64  "Set a new commercial skip list in the form:\n"
65  "#-#[,#-#]... (ie, 1-100,1520-3012,4091-5094)", "")
66  ->SetGroup("Recording Markup")
67  ->SetParentOf(ChanidStartimeVideo)
68  << add("--clearskiplist", "clearskiplist", false,
69  "Clear the commercial skip list.", "")
70  ->SetGroup("Recording Markup")
71  ->SetParentOf(ChanidStartimeVideo)
72  << add("--clearseektable", "clearseektable", false,
73  "Clear the seek table.", "")
74  ->SetGroup("Recording Markup")
75  ->SetParentOf(ChanidStartimeVideo)
76  << add("--clearbookmarks", "clearbookmarks", false,
77  "Clear all bookmarks.", "This command will reset the playback "
78  "start to the very beginning of the recording file.")
79  ->SetGroup("Recording Markup")
80  ->SetParentOf(ChanidStartimeVideo)
81  << add("--getmarkup", "getmarkup", "",
82  "Write markup data to the specified local file.", "")
83  ->SetGroup("Recording Markup")
84  ->SetParentOf(ChanidStartimeVideo)
85  << add("--setmarkup", "setmarkup", "",
86  "Read markup data from the specified local file, and\n"
87  "use it to set the markup for the recording or video.", "")
88  ->SetGroup("Recording Markup")
89  ->SetParentOf(ChanidStartimeVideo)
90 
91  // backendutils.cpp
92  << add("--resched", "resched", false,
93  "Trigger a run of the recording scheduler on the existing "
94  "master backend.",
95  "This command will connect to the master backend and trigger "
96  "a run of the recording scheduler. The call will return "
97  "immediately, however the scheduler run may take several "
98  "seconds to a minute or longer to complete.")
99  ->SetGroup("Backend")
100  << add("--scanvideos", "scanvideos", false,
101  "Trigger a rescan of media content in MythVideo.",
102  "This command will connect to the master backend and trigger "
103  "a run of the Video scanner. The call will return "
104  "immediately, however the scanner may take several seconds "
105  "to tens of minutes, depending on how much new or moved "
106  "content it has to hash, and how quickly the scanner can "
107  "access those files to do so. If enabled, this will also "
108  "trigger the bulk metadata scanner upon completion.")
109  ->SetGroup("Backend")
110  << add("--event", "event", QVariant::StringList,
111  "Send a backend event test message.", "")
112  ->SetGroup("Backend")
113  << add("--systemevent", "systemevent", "",
114  "Send a backend SYSTEM_EVENT test message.", "")
115  ->SetGroup("Backend")
116  << add("--clearcache", "clearcache", false,
117  "Trigger a cache clear on all connected MythTV systems.",
118  "This command will connect to the master backend and trigger "
119  "a cache clear event, which will subsequently be pushed to "
120  "all other connected programs. This event will clear the "
121  "local database settings cache used by each program, causing "
122  "options to be re-read from the database upon next use.")
123  ->SetGroup("Backend")
124  << add("--parse-video-filename", "parsevideo", "", "",
125  "Diagnostic tool for testing filename formats against what "
126  "the Video Library name parser will detect them as.")
127  ->SetGroup("Backend")
128 
129  // jobutils.cpp
130  << add("--queuejob", "queuejob", "",
131  "Insert a new job into the JobQueue.",
132  "Schedule the specified job type (transcode, commflag, "
133  "metadata, userjob1, userjob2, userjob3, userjob4) to run "
134  "for the recording with the given chanid and starttime.")
135  ->SetGroup("JobQueue")
136  ->SetRequiredChild("chanid")
137  ->SetRequiredChild("starttime")
138 
139  // messageutils.cpp
140  << add("--message", "message", false,
141  "Display a message on a frontend", "")
142  ->SetGroup("Messaging")
143  << add("--print-message-template", "printmtemplate", false,
144  "Print the template to be sent to the frontend", "")
145  ->SetGroup("Messaging")
146  << add("--notification", "notification", false,
147  "Display a notification on a frontend", "")
148  ->SetGroup("Messaging")
149  << add("--print-notification-template", "printntemplate", false,
150  "Print the template to be sent to the frontend", "")
151  ->SetGroup("Messaging")
152 
153  // musicmetautils.cpp
154  << add("--scanmusic", "scanmusic", false,
155  "Scan the 'Music' Storage Group for music files", "")
156  ->SetGroup("Music Scanning")
157  << add("--updateradiostreams", "updateradiostreams", false,
158  "Downloads an updated radio stream list from the MythTV server", "")
159  ->SetGroup("Music Scanning")
160  << add("--updatemeta", "updatemeta", false,
161  "Update a music tracks database record and tag with new metadata", "")
162  ->SetGroup("Metadata Reading/Writing")
163  << add("--extractimage", "extractimage", false,
164  "Extract an embedded image from a tracks tag and cache it in the AlbumArt storage group", "")
165  ->SetGroup("Metadata Reading/Writing")
166  << add("--calctracklen", "calctracklen", false,
167  "Decode a track to determine its exact length", "")
168  ->SetGroup("Metadata Reading/Writing")
169  << add("--findlyrics", "findlyrics", false,
170  "Search for some lyrics for a track", "")
171  ->SetGroup("Metadata Reading/Writing")
172  ->SetRequiredChild(QStringList("songid"))
173  ->SetParentOf(QStringList() << "artist" << "album" << "title")
174 
175  // recordingutils.cpp
176  << add("--checkrecordings", "checkrecordings", false,
177  "Check all recording exist and have a seektable etc.", "")
178  ->SetGroup("Recording Utils")
179 
180  // eitutils.cpp
181  << add("--cleareit", "cleareit", false,
182  "Clear guide received from EIT.", "")
183  ->SetGroup("EIT Utils")
184  );
185 
186  // mpegutils.cpp
187  add("--pids", "pids", "", "Pids to process", "")
188  ->SetRequiredChildOf("pidfilter")
189  ->SetRequiredChildOf("pidprinter");
190  add("--ptspids", "ptspids", "", "Pids to extract PTS from", "")
191  ->SetGroup("MPEG-TS");
192  add("--packetsize", "packetsize", 188, "TS Packet Size", "")
193  ->SetChildOf("pidcounter")
194  ->SetChildOf("pidfilter");
195  add("--noautopts", "noautopts", false, "Disables PTS discovery", "")
196  ->SetChildOf("pidprinter");
197  add("--xml", "xml", false, "Enables XML output of PSIP", "")
198  ->SetChildOf("pidprinter");
199 
200  // messageutils.cpp
201  add("--message_text", "message_text", "message", "(optional) message to send", "")
202  ->SetChildOf("message")
203  ->SetChildOf("notification");
204  add("--timeout", "timeout", 0, "(optional) notification duration", "")
205  ->SetChildOf("message")
206  ->SetChildOf("notification");
207  add("--udpport", "udpport", 6948, "(optional) UDP Port to send to", "")
208  ->SetChildOf("message")
209  ->SetChildOf("notification");
210  add("--bcastaddr", "bcastaddr", "127.0.0.1", "(optional) IP address to send to", "")
211  ->SetChildOf("message")
212  ->SetChildOf("notification");
213  add("--image", "image", "image_path", "(optional) Path to image to send to (http://, myth://)", "")
214  ->SetChildOf("notification");
215  add("--origin", "origin", "text", "(optional) notification origin text", "")
216  ->SetChildOf("notification");
217  add("--description", "description", "text", "(optional) notification description text", "")
218  ->SetChildOf("notification");
219  add("--extra", "extra", "text", "(optional) notification extra text", "")
220  ->SetChildOf("notification");
221  add("--progress_text", "progress_text", "text", "(optional) notification progress text", "")
222  ->SetChildOf("notification");
223  add("--progress", "progress", -1.0, "(optional) progress value (must be between 0 and 1)", "")
224  ->SetChildOf("notification");
225  add("--fullscreen", "fullscreen", false, "(optional) display notification in full screen mode", "")
226  ->SetChildOf("notification");
227  add("--error", "error", false, "(optional) set notification to be displayed as an error", "")
228  ->SetChildOf("notification");
229  add("--visibility", "visibility", 0, "(optional) bitmask indicating where to show the notification", "")
230  ->SetChildOf("notification");
231  add("--type", "type", "type", "(optional) type of notification (normal, error, warning, check, busy", "")
232  ->SetChildOf("notification");
233 
234  // musicmetautils.cpp
235  add("--songid", "songid", "", "ID of track to update", "")
236  ->SetChildOf("updatemeta");
237  add("--title", "title", "", "(optional) Title of track", "")
238  ->SetChildOf("updatemeta");
239  add("--artist", "artist", "", "(optional) Artist of track", "")
240  ->SetChildOf("updatemeta");
241  add("--album", "album", "", "(optional) Album of track", "")
242  ->SetChildOf("updatemeta");
243  add("--genre", "genre", "", "(optional) Genre of track", "")
244  ->SetChildOf("updatemeta");
245  add("--trackno", "trackno", "", "(optional) Track No. of track", "")
246  ->SetChildOf("updatemeta");
247  add("--year", "year", "", "(optional) Year of track", "")
248  ->SetChildOf("updatemeta");
249  add("--rating", "rating", "", "(optional) Rating of track", "")
250  ->SetChildOf("updatemeta");
251  add("--playcount", "playcount", "", "(optional) Playcount of track", "")
252  ->SetChildOf("updatemeta");
253  add("--lastplayed", "lastplayed", "", "(optional) Last played of track", "")
254  ->SetChildOf("updatemeta");
255  add("--songid", "songid", "", "ID of track from which to get the image", "")
256  ->SetChildOf("extractimage");
257  add("--imagetype", "imagetype", "", "Type of image to extract (front, back, cd, inlay, unknown)", "")
258  ->SetChildOf("extractimage");
259  add("--songid", "songid", "", "ID of track to determine the length", "")
260  ->SetChildOf("calctracklen");
261  add("--songid", "songid", "", "ID of track to find lyrics for", "")
262  ->SetChildOf("findlyrics");
263  add("--grabber", "grabber", "", "(optional) Name of grabber to use or 'ALL' to try all available grabbers", "")
264  ->SetChildOf("findlyrics");
265  add("--artist", "grabber", "", "(optional) Artist of track to find lyrics for", "")
266  ->SetChildOf("findlyrics");
267  add("--album", "grabber", "", "(optional) Album of track to find lyrics for", "")
268  ->SetChildOf("findlyrics");
269  add("--title", "grabber", "", "(optional) Title of track to find lyrics for", "")
270  ->SetChildOf("findlyrics");
271 
272  // recordingutils.cpp
273  add("--fixseektable", "fixseektable", false, "(optional) fix the seektable if missing for a recording", "")
274  ->SetChildOf("checkrecordings");
275 
276  // eitutils.cpp
277  add("--sourceid", "sourceid", -1, "(optional) specify sourceid of video source to operate on instead of all", "")
278  ->SetChildOf("cleareit");
279 
280  // Generic Options used by more than one utility
281  addRecording();
282  addInFile(true);
284  addHelp();
285  addVersion();
286  addLogging();
287  allowExtras();
288  // Note: This globally prevents --chanid and --video from being
289  // used together, but this is almost certainly a valid restriction
290  // in all cases.
291  CommandLineArg::AllowOneOf(QList<CommandLineArg*>() <<
292  new CommandLineArg("chanid") <<
293  add("--video", "video", "",
294  "Specify path name of Video Gallery video "
295  "to operate on.", ""));
296 }
297 
299 {
300  return "MythUtil is a command line utility application for MythTV.";
301 }
302 
303 /* vim: set expandtab tabstop=4 shiftwidth=4: */
CommandLineArg * add(QString arg, QString name, bool def, QString help, QString longhelp)
Parent class for defining application command line parsers.
void allowExtras(bool allow=true)
Specify that parser should allow and collect additional key/value pairs not explicitly defined for pr...
void addVersion(void)
Canned argument definition for –version.
Definition for a single command line option.
void addLogging(const QString &defaultVerbosity="general", LogLevel_t defaultLogLevel=LOG_INFO)
Canned argument definition for all logging options, including –verbose, –logpath, –quiet,...
void addHelp(void)
Canned argument definition for –help.
void addInFile(bool addOutFile=false)
Canned argument definition for –infile and –outfile.
CommandLineArg * SetChildOf(const QString &opt)
Set argument as child of given parent.
static void AllowOneOf(QList< CommandLineArg * > args)
Mark a list of arguments as mutually exclusive.
#define MYTH_APPNAME_MYTHUTIL
CommandLineArg * SetGroup(const QString &group)
QString GetHelpHeader(void) const override
void addSettingsOverride(void)
Canned argument definition for –override-setting and –override-settings-file.
CommandLineArg * SetRequiredChildOf(const QString &opt)
Set argument as child required by given parent.
void addRecording(void)
Canned argument definition for –chanid and –starttime.