Skip to content

Commit

Permalink
Add usage information and -h option
Browse files Browse the repository at this point in the history
  • Loading branch information
c3d committed Oct 18, 2017
1 parent 973e8bb commit e7f8db5
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions scope/recorder_scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@
#include <QtWidgets/QVBoxLayout>


void usage(const char *progname)
// ----------------------------------------------------------------------------
// Display usage information about the program
// ----------------------------------------------------------------------------
{
printf("Usage: %s [[-c config][-s slider][chan_re]...]\n"
"\n"
" Arguments:\n"
" -c config : Send configuration command\n"
" -s slider : Setup a control slider\n"
" chan_re : Add view with channels matching regexp\n"
"\n"
" Configuration syntax for -c matches RECORDER_TRACES syntax\n"
" Slider syntax is slider[=value[:min:max]]\n"
"\n"
" See http://github.com/c3d/recorder for more information\n"
"\n"
" Examples of arguments:\n"
" -c '.*errors' : Enable display of all errors\n"
" -c rate=10 : Set 'rate' tweak to 10\n"
" -s rate=10:2:39 : Create slider to set 'rate'\n"
" initial value 10, range 2 to 39\n"
" my_graph : Show graph for channel 'my_graph'\n"
" (min|max)_rate : Show min_rate and max_rate graph\n",
progname);
}


int main(int argc, char *argv[])
// ----------------------------------------------------------------------------
// Create the main widget for the oscilloscope and display it
Expand All @@ -50,25 +78,34 @@ int main(int argc, char *argv[])
for (int a = 1; a < argc; a++)
{
QString arg = argv[a];
if (arg == "-c" && ++a < argc)
if (arg == "-h")
{
usage(argv[0]);
}
else if (arg == "-c" && a+1 < argc)
{
if (!recorder_chans_configure(chans, argv[a]))
if (!recorder_chans_configure(chans, argv[++a]))
{
fprintf(stderr, "Insufficient command space to send '%s'\n",
argv[a]);
return 3;
}
configurations++;
}
else if (arg == "-s" && ++a < argc)
else if (arg == "-s" && a+1 < argc)
{
QGroupBox *slider = RecorderSlider::make(path, chans, argv[a]);
QGroupBox *slider = RecorderSlider::make(path, chans, argv[++a]);
layout->addWidget(slider);
}
else if (arg[0] == '-')
{
fprintf(stderr, "Invalid option %s\n", argv[a]);
usage(argv[0]);
}
else
{
RecorderView *recorderView = new RecorderView(path, chans, argv[a]);
layout->addWidget(recorderView);
RecorderView *view = new RecorderView(path, chans, argv[a]);
layout->addWidget(view);
views++;
}
}
Expand Down

0 comments on commit e7f8db5

Please sign in to comment.