mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
QQQ-14 feedback from code review
This commit is contained in:
2
pom.xml
2
pom.xml
@ -51,7 +51,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.kingsrook.qqq</groupId>
|
<groupId>com.kingsrook.qqq</groupId>
|
||||||
<artifactId>qqq-backend-core</artifactId>
|
<artifactId>qqq-backend-core</artifactId>
|
||||||
<version>0.0.0-20220624.134906-11</version>
|
<version>0.0.0-20220630.172133-16</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.kingsrook.qqq</groupId>
|
<groupId>com.kingsrook.qqq</groupId>
|
||||||
|
@ -257,7 +257,7 @@ public class QPicoCliImplementation
|
|||||||
{
|
{
|
||||||
case "processes":
|
case "processes":
|
||||||
{
|
{
|
||||||
return runTableProcess(subCommandLine, null, subParseResult);
|
return runProcessCommand(subCommandLine, subParseResult);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -308,7 +308,7 @@ public class QPicoCliImplementation
|
|||||||
case "process":
|
case "process":
|
||||||
{
|
{
|
||||||
CommandLine subCommandLine = commandLine.getSubcommands().get(subCommandName);
|
CommandLine subCommandLine = commandLine.getSubcommands().get(subCommandName);
|
||||||
return runTableProcess(subCommandLine, tableName, subParseResult);
|
return runProcessCommand(subCommandLine, subParseResult);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -328,29 +328,35 @@ public class QPicoCliImplementation
|
|||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
** Handle a command up to the point where 'process' was given
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
private int runTableProcess(CommandLine commandLine, String tableName, ParseResult subParseResult)
|
private int runProcessCommand(CommandLine commandLine, ParseResult subParseResult)
|
||||||
{
|
{
|
||||||
if(!subParseResult.hasSubcommand())
|
if(!subParseResult.hasSubcommand())
|
||||||
{
|
{
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
// process name must be a sub-command, so, error if not given //
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
commandLine.usage(commandLine.getOut());
|
commandLine.usage(commandLine.getOut());
|
||||||
return commandLine.getCommandSpec().exitCodeOnUsageHelp();
|
return commandLine.getCommandSpec().exitCodeOnUsageHelp();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// move on to running the actual process //
|
||||||
|
///////////////////////////////////////////
|
||||||
String subCommandName = subParseResult.subcommand().commandSpec().name();
|
String subCommandName = subParseResult.subcommand().commandSpec().name();
|
||||||
CommandLine subCommandLine = commandLine.getSubcommands().get(subCommandName);
|
CommandLine subCommandLine = commandLine.getSubcommands().get(subCommandName);
|
||||||
return runTableProcessLevelCommand(subCommandLine, tableName, subParseResult.subcommand());
|
return runActualProcess(subCommandLine, subParseResult.subcommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
** actually run a process (the process name should be at the start of the sub-command line)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
private int runTableProcessLevelCommand(CommandLine subCommandLine, String tableName, ParseResult processParseResult)
|
private int runActualProcess(CommandLine subCommandLine, ParseResult processParseResult)
|
||||||
{
|
{
|
||||||
String processName = processParseResult.commandSpec().name();
|
String processName = processParseResult.commandSpec().name();
|
||||||
QProcessMetaData process = qInstance.getProcess(processName);
|
QProcessMetaData process = qInstance.getProcess(processName);
|
||||||
@ -386,7 +392,7 @@ public class QPicoCliImplementation
|
|||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
subCommandLine.getOut().println("Caught Exception running process: " + e); // todo better!
|
subCommandLine.getOut().println("Caught Exception running process. See stack trace above for details.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class QPicoCliImplementationTest
|
|||||||
JSONObject processes = metaData.getJSONObject("processes");
|
JSONObject processes = metaData.getJSONObject("processes");
|
||||||
JSONObject greetProcess = processes.getJSONObject("greet");
|
JSONObject greetProcess = processes.getJSONObject("greet");
|
||||||
assertEquals("greet", greetProcess.getString("name"));
|
assertEquals("greet", greetProcess.getString("name"));
|
||||||
// todo - need label assertEquals("Person", greetProcess.getString("label"));
|
assertEquals("Greet", greetProcess.getString("label"));
|
||||||
assertEquals("person", greetProcess.getString("tableName"));
|
assertEquals("person", greetProcess.getString("tableName"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ package com.kingsrook.qqq.frontend.picocli;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import com.kingsrook.qqq.backend.core.interfaces.mock.MockFunctionBody;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.QAuthenticationMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.QAuthenticationMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.QCodeReference;
|
import com.kingsrook.qqq.backend.core.model.metadata.QCodeReference;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.QCodeType;
|
import com.kingsrook.qqq.backend.core.model.metadata.QCodeType;
|
||||||
@ -168,7 +169,7 @@ public class TestUtils
|
|||||||
.addFunction(new QFunctionMetaData()
|
.addFunction(new QFunctionMetaData()
|
||||||
.withName("prepare")
|
.withName("prepare")
|
||||||
.withCode(new QCodeReference()
|
.withCode(new QCodeReference()
|
||||||
.withName("com.kingsrook.qqq.backend.core.interfaces.mock.MockFunctionBody")
|
.withName(MockFunctionBody.class.getName())
|
||||||
.withCodeType(QCodeType.JAVA)
|
.withCodeType(QCodeType.JAVA)
|
||||||
.withCodeUsage(QCodeUsage.FUNCTION)) // todo - needed, or implied in this context?
|
.withCodeUsage(QCodeUsage.FUNCTION)) // todo - needed, or implied in this context?
|
||||||
.withInputData(new QFunctionInputMetaData()
|
.withInputData(new QFunctionInputMetaData()
|
||||||
|
Reference in New Issue
Block a user