mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 10:55:46 -05:00
[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
1 changed files with 15 additions and 7 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include "GeoIPFixed.h"
|
||||
#include "GeoIPJSON.h"
|
||||
#ifdef QT_XML_LIB
|
||||
#include "GeoIPXML.h"
|
||||
|
@ -33,27 +34,34 @@ using namespace CalamaresUtils::GeoIP;
|
|||
int
|
||||
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;
|
||||
}
|
||||
|
||||
QString format( argv[ 1 ] );
|
||||
QString selector = argc == 3 ? QString( argv[ 2 ] ) : QString();
|
||||
|
||||
Interface* handler = nullptr;
|
||||
if ( QStringLiteral( "json" ) == argv[ 1 ] )
|
||||
if ( QStringLiteral( "json" ) == format )
|
||||
{
|
||||
handler = new GeoIPJSON;
|
||||
handler = new GeoIPJSON( selector );
|
||||
}
|
||||
#ifdef QT_XML_LIB
|
||||
else if ( QStringLiteral( "xml" ) == argv[ 1 ] )
|
||||
else if ( QStringLiteral( "xml" ) == format )
|
||||
{
|
||||
handler = new GeoIPXML;
|
||||
handler = new GeoIPXML( selector );
|
||||
}
|
||||
#endif
|
||||
else if ( QStringLiteral( "fixed" ) == format )
|
||||
{
|
||||
handler = new GeoIPFixed( selector );
|
||||
}
|
||||
|
||||
if ( !handler )
|
||||
{
|
||||
cerr << "Unknown format '" << argv[ 1 ] << "'\n";
|
||||
cerr << "Unknown format '" << format.toLatin1().constData() << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue