[libcalamares] Add GeoIPFixed to the test-tool for GeoIP lookup
- Allow format "fixed" - Allow specifying the selector in the test-tool
This commit is contained in:
parent
d37ec35592
commit
d9effb4ba7
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "GeoIPFixed.h"
|
||||||
#include "GeoIPJSON.h"
|
#include "GeoIPJSON.h"
|
||||||
#ifdef QT_XML_LIB
|
#ifdef QT_XML_LIB
|
||||||
#include "GeoIPXML.h"
|
#include "GeoIPXML.h"
|
||||||
@ -33,27 +34,34 @@ using namespace CalamaresUtils::GeoIP;
|
|||||||
int
|
int
|
||||||
main( int argc, char** argv )
|
main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
if ( argc != 2 )
|
if ( ( argc != 2 ) && ( argc != 3 ) )
|
||||||
{
|
{
|
||||||
cerr << "Usage: curl url | test_geoip <format>\n";
|
cerr << "Usage: curl url | test_geoip <format> [selector]\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString format( argv[ 1 ] );
|
||||||
|
QString selector = argc == 3 ? QString( argv[ 2 ] ) : QString();
|
||||||
|
|
||||||
Interface* handler = nullptr;
|
Interface* handler = nullptr;
|
||||||
if ( QStringLiteral( "json" ) == argv[ 1 ] )
|
if ( QStringLiteral( "json" ) == format )
|
||||||
{
|
{
|
||||||
handler = new GeoIPJSON;
|
handler = new GeoIPJSON( selector );
|
||||||
}
|
}
|
||||||
#ifdef QT_XML_LIB
|
#ifdef QT_XML_LIB
|
||||||
else if ( QStringLiteral( "xml" ) == argv[ 1 ] )
|
else if ( QStringLiteral( "xml" ) == format )
|
||||||
{
|
{
|
||||||
handler = new GeoIPXML;
|
handler = new GeoIPXML( selector );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
else if ( QStringLiteral( "fixed" ) == format )
|
||||||
|
{
|
||||||
|
handler = new GeoIPFixed( selector );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !handler )
|
if ( !handler )
|
||||||
{
|
{
|
||||||
cerr << "Unknown format '" << argv[ 1 ] << "'\n";
|
cerr << "Unknown format '" << format.toLatin1().constData() << "'\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user