mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-30 02:45:37 -04:00
[libcalamares] Implement object-style command line
- handle command: and timeout: entries - test for setting the values
This commit is contained in:
parent
72bac332be
commit
c641f5dec6
3 changed files with 46 additions and 1 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
|
||||
#include "utils/CalamaresUtils.h"
|
||||
#include "utils/CalamaresUtilsSystem.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
|
@ -29,6 +30,17 @@
|
|||
namespace CalamaresUtils
|
||||
{
|
||||
|
||||
static CommandLine get_variant_object( const QVariantMap& m )
|
||||
{
|
||||
QString command = CalamaresUtils::getString( m, "command" );
|
||||
int timeout = CalamaresUtils::getInteger( m, "timeout", -1 );
|
||||
|
||||
if ( !command.isEmpty() )
|
||||
return CommandLine( command, timeout );
|
||||
cDebug() << "WARNING Bad CommandLine element" << m;
|
||||
return CommandLine();
|
||||
}
|
||||
|
||||
static CommandList_t get_variant_stringlist( const QVariantList& l, int timeout )
|
||||
{
|
||||
CommandList_t retl;
|
||||
|
@ -37,6 +49,13 @@ static CommandList_t get_variant_stringlist( const QVariantList& l, int timeout
|
|||
{
|
||||
if ( v.type() == QVariant::String )
|
||||
retl.append( CommandLine( v.toString(), timeout ) );
|
||||
else if ( v.type() == QVariant::Map )
|
||||
{
|
||||
auto c( get_variant_object( v.toMap() ) );
|
||||
if ( c.isValid() )
|
||||
retl.append( c );
|
||||
// Otherwise warning is already given
|
||||
}
|
||||
else
|
||||
cDebug() << "WARNING Bad CommandList element" << c << v.type() << v;
|
||||
++c;
|
||||
|
@ -63,6 +82,13 @@ CommandList::CommandList::CommandList( const QVariant& v, bool doChroot, int tim
|
|||
}
|
||||
else if ( v.type() == QVariant::String )
|
||||
append( v.toString() );
|
||||
else if ( v.type() == QVariant::Map )
|
||||
{
|
||||
auto c( get_variant_object( v.toMap() ) );
|
||||
if ( c.isValid() )
|
||||
append( c );
|
||||
// Otherwise warning is already given
|
||||
}
|
||||
else
|
||||
cDebug() << "WARNING: CommandList does not understand variant" << v.type();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue