Add version CLI option for all executables

pull/92/head
Leif Sawyer 2020-01-21 09:13:29 -09:00
parent 2095540d53
commit 079509811d
12 changed files with 276 additions and 16 deletions

View File

@ -36,34 +36,34 @@ clean:
decrypt: decrypt.o bits.o ext/fmt-5.2.1/src/format.o
$(CXX) -std=gnu++17 $^ -o $@
navparse: navparse.o ext/fmt-5.2.1/src/format.o $(H2OPP) $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o trkmeas.o influxpush.o ${EXTRADEP}
navparse: navparse.o ext/fmt-5.2.1/src/format.o $(H2OPP) $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o trkmeas.o influxpush.o ${EXTRADEP} githash.o
$(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -L/usr/local/opt/openssl/lib/ -lh2o-evloop -lssl -lcrypto -lz -lcurl -lprotobuf $(WSLAY)
reporter: reporter.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o
reporter: reporter.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o githash.o
$(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf -lcurl
galmonmon: galmonmon.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o githash.o
$(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf -lcurl
navdump: navdump.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o navmon.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o sp3.o osen.o trkmeas.o ${EXTRADEP}
navdump: navdump.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o navmon.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o sp3.o osen.o trkmeas.o githash.o ${EXTRADEP}
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf
navdisplay: navdisplay.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o ephemeris.o navmon.o osen.o
navdisplay: navdisplay.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o ephemeris.o navmon.o osen.o githash.o
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf -lncurses
navnexus: navnexus.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o
navnexus: navnexus.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o githash.o
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf
navcat: navcat.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o navmon.o
navcat: navcat.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o navmon.o githash.o
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf
navrecv: navrecv.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) navmon.pb.o storage.o
navrecv: navrecv.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) navmon.pb.o storage.o githash.o
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf
tlecatch: tlecatch.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc))
tlecatch: tlecatch.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) githash.o
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf
navmon.pb.cc: navmon.proto

View File

@ -7,8 +7,20 @@
#include "ext/powerblog/h2o-pp.hh"
#include <variant>
#include "githash.h"
#include "CLI/CLI.hpp"
#include "version.hh"
static char program[]="galmonmon";
using namespace std;
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
/*
Monitoring the satellites for sensible alerts.
@ -164,15 +176,29 @@ int main(int argc, char **argv)
MiniCurl::MiniCurlHeaders mch;
// string url="https://galmon.eu/svs.json";
string url="http://[::1]:10000/";
bool doVERSION{false};
CLI::App app(program);
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion();
exit(0);
}
g_sk.setBoolNames("health", "healthy", "unhealthy");
g_sk.setBoolNames("eph-too-old", "ephemeris fresh", "ephemeris too old");
g_sk.setBoolNames("silent", "observed", "not observed");
std::variant<bool, string> tst;
extern const char* g_gitHash;
auto observers = nlohmann::json::parse(mc.getURL(url+"observers.json"));
cout<<("Galmonmon " +string(g_gitHash)+ " started, " + std::to_string(observers.size()) +" observers seen")<<endl;

View File

@ -16,9 +16,21 @@
#include <dirent.h>
#include <inttypes.h>
#include "navmon.hh"
#include "githash.h"
#include "CLI/CLI.hpp"
#include "version.hh"
static char program[]="navcat";
using namespace std;
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
void unixDie(const std::string& str)
{
throw std::runtime_error(str+string(": ")+string(strerror(errno)));
@ -163,6 +175,23 @@ void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0)
int main(int argc, char** argv)
{
bool doVERSION{false};
CLI::App app(program);
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion();
exit(0);
}
signal(SIGPIPE, SIG_IGN);
if(argc < 3) {
cout<<"Syntax: navcat storage start stop"<<endl;

View File

@ -13,8 +13,20 @@
#include "navmon.pb.h"
#include <unistd.h>
#include "navmon.hh"
#include "githash.h"
#include "CLI/CLI.hpp"
#include "version.hh"
static char program[]="navdisplay";
using namespace std;
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
struct WinKeeper
{

View File

@ -26,8 +26,20 @@
#include "sp3.hh"
#include "ubx.hh"
#include <unistd.h>
#include "githash.h"
#include "version.hh"
static char program[]="navdump";
using namespace std;
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
Point g_ourpos;
@ -226,7 +238,7 @@ try
{
GOOGLE_PROTOBUF_VERIFY_VERSION;
CLI::App app("navdump");
CLI::App app(program);
TLERepo tles;
@ -247,16 +259,22 @@ try
bool doReceptionData{false};
bool doRFData{true};
bool doObserverPosition{false};
bool doVERSION{false};
app.add_option("--svs", svpairs, "Listen to specified svs. '0' = gps, '2' = Galileo, '2,1' is E01");
app.add_option("--stations", stations, "Listen to specified stations.");
app.add_option("--positions,-p", doObserverPosition, "Print out observer positions (or not)");
app.add_option("--rfdata,-r", doRFData, "Print out RF data (or not)");
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion();
exit(0);
}
SVFilter svfilter;
for(const auto& svp : svpairs) {
svfilter.addFilter(svp);

View File

@ -15,9 +15,22 @@
#include "storage.hh"
#include <dirent.h>
#include <inttypes.h>
#include "githash.h"
#include "CLI/CLI.hpp"
#include "version.hh"
static char program[]="navnexus";
using namespace std;
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
std::mutex g_clientmut;
set<int> g_clients;
@ -143,6 +156,23 @@ void sendListener(Socket&& s, ComboAddress local, int hours)
int main(int argc, char** argv)
{
bool doVERSION{false};
CLI::App app(program);
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion();
exit(0);
}
signal(SIGPIPE, SIG_IGN);
if(argc < 3) {
cout<<"Syntax: navnexus storage listen-address [backlog-hours]"<<endl;

View File

@ -30,9 +30,21 @@
#include "navparse.hh"
#include <fenv.h>
#include "influxpush.hh"
#include "githash.h"
#include "CLI/CLI.hpp"
#include "version.hh"
static char program[]="navparse";
using namespace std;
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
struct ObserverPosition
{
Point pos;
@ -415,6 +427,23 @@ void addHeaders(h2o_req_t* req)
int main(int argc, char** argv)
try
{
bool doVERSION{false};
CLI::App app(program);
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion();
exit(0);
}
// feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );

View File

@ -11,8 +11,21 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "githash.h"
#include "CLI/CLI.hpp"
#include "version.hh"
static char program[]="navrecv";
using namespace std;
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
/* Goals in life:
1) NEVER EVER GO DOWN
@ -181,6 +194,23 @@ void recvListener(Socket&& s, ComboAddress local)
int main(int argc, char** argv)
{
bool doVERSION{false};
CLI::App app(program);
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion();
exit(0);
}
signal(SIGPIPE, SIG_IGN);
if(argc != 3) {
cout<<"Syntax: navrecv listen-address storage"<<endl;

View File

@ -4,9 +4,21 @@
#include "navmon.hh"
#include "fmt/format.h"
#include "fmt/printf.h"
#include "githash.h"
#include "CLI/CLI.hpp"
#include "version.hh"
static char program[]="reporter";
using namespace std;
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
/*
Goal: generate statistics from influxdb.
@ -45,6 +57,23 @@ int main(int argc, char **argv)
string url="http://127.0.0.1:8086/query?db="+dbname+"&epoch=s&q=";
string period="time > now() - 1w";
int sigid=1;
bool doVERSION{false};
CLI::App app(program);
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion();
exit(0);
}
if(argc == 2)
period = "time > now() - "+string(argv[1]);
if(argc == 3) {

View File

@ -1,7 +1,21 @@
#include "SGP4.h"
#include <string>
#include <time.h>
#include "githash.h"
#include "CLI/CLI.hpp"
#include "version.hh"
static char program[]="tlecatch";
using namespace std;
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
int main(int argc, char **argv)
{
string line;
@ -9,7 +23,23 @@ int main(int argc, char **argv)
time_t now = time(0);
struct tm tm;
gmtime_r(&now, &tm);
bool doVERSION{false};
CLI::App app(program);
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion();
exit(0);
}
for(;;) {
DateTime d(1900 + tm.tm_year, tm.tm_mon+1, tm.tm_mday, 04, 43, 51);
string name, line1, line2;

View File

@ -32,9 +32,13 @@
#include "swrappers.hh"
#include "sclasses.hh"
#include "githash.h"
#include "version.hh"
static char program[]="ubxtool";
bool doDEBUG{false};
bool doLOGFILE{false};
bool doVERSION{false};
struct timespec g_gnssutc;
uint16_t g_galwn;
@ -44,6 +48,12 @@ using namespace std;
uint16_t g_srcid{0};
int g_fixtype{-1};
double g_speed{-1};
extern const char* g_gitHash;
void showVersion()
{
_showVersion(program,g_gitHash)
}
static int getBaudrate(int baud)
{
@ -534,7 +544,7 @@ int main(int argc, char** argv)
time_t starttime=time(0);
GOOGLE_PROTOBUF_VERIFY_VERSION;
CLI::App app("ubxtool");
CLI::App app(program);
bool doGPS{true}, doGalileo{true}, doGlonass{false}, doBeidou{true}, doReset{false}, doWait{true}, doRTSCTS{true}, doSBAS{false};
@ -563,7 +573,7 @@ int main(int argc, char** argv)
app.add_flag("--sbas,-s", doSBAS, "Enable SBAS (EGNOS/WAAS/etc) reception");
app.add_option("--rtscts", doRTSCTS, "Set hardware handshaking");
app.add_flag("--stdout", doSTDOUT, "Emit output to stdout");
app.add_option("--port,-p", portName, "Device or file to read serial from")->required();
auto pn = app.add_option("--port,-p", portName, "Device or file to read serial from");
app.add_option("--station", g_srcid, "Station id");
app.add_option("--ubxport,-u", ubxport, "UBX port to enable messages on (usb=3)");
app.add_option("--baud,-b", baudrate, "Baudrate for serial connection");
@ -581,12 +591,22 @@ int main(int argc, char** argv)
app.add_flag("--survey-reset", doSurveyReset, "Reset the Surveyed-in state");
app.add_flag("--debug", doDEBUG, "Display debug information");
app.add_flag("--logfile", doLOGFILE, "Create logfile");
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion();
exit(0);
}
if(! *pn) {
cerr<<"you must provide the --port"<<endl;
exit(1);
}
g_baudval = getBaudrate(baudrate);
@ -1529,7 +1549,6 @@ int main(int argc, char** argv)
nmm.mutable_od()->set_owner(owner);
nmm.mutable_od()->set_remark(remark);
extern const char* g_gitHash;
nmm.mutable_od()->set_recvgithash(g_gitHash);
nmm.mutable_od()->set_uptime(time(0) - starttime);

8
version.hh 100644
View File

@ -0,0 +1,8 @@
#pragma once
#define _showVersion(program,g_gitHash) { \
cout <<"galmon tools (" <<program <<") " <<g_gitHash <<endl; \
cout <<"built date " <<__DATE__ <<endl; \
cout <<"(C) AHU Holding BV - bert@hubertnet.nl - https://berthub.eu/" <<endl; \
cout <<"https://galmon.eu/ - https://github.com/ahupowerdns/galmon" <<endl; \
cout <<"License GPLv3: GNU GPL version 3 https://gnu.org/licenses/gpl.html" <<endl; }