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>
|
||||
<groupId>com.kingsrook.qqq</groupId>
|
||||
<artifactId>qqq-backend-core</artifactId>
|
||||
<version>0.0.0-20220624.134906-11</version>
|
||||
<version>0.0.0-20220630.172133-16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.kingsrook.qqq</groupId>
|
||||
|
@ -257,7 +257,7 @@ public class QPicoCliImplementation
|
||||
{
|
||||
case "processes":
|
||||
{
|
||||
return runTableProcess(subCommandLine, null, subParseResult);
|
||||
return runProcessCommand(subCommandLine, subParseResult);
|
||||
}
|
||||
default:
|
||||
{
|
||||
@ -308,7 +308,7 @@ public class QPicoCliImplementation
|
||||
case "process":
|
||||
{
|
||||
CommandLine subCommandLine = commandLine.getSubcommands().get(subCommandName);
|
||||
return runTableProcess(subCommandLine, tableName, subParseResult);
|
||||
return runProcessCommand(subCommandLine, subParseResult);
|
||||
}
|
||||
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())
|
||||
{
|
||||
////////////////////////////////////////////////////////////////
|
||||
// process name must be a sub-command, so, error if not given //
|
||||
////////////////////////////////////////////////////////////////
|
||||
commandLine.usage(commandLine.getOut());
|
||||
return commandLine.getCommandSpec().exitCodeOnUsageHelp();
|
||||
}
|
||||
else
|
||||
{
|
||||
///////////////////////////////////////////
|
||||
// move on to running the actual process //
|
||||
///////////////////////////////////////////
|
||||
String subCommandName = subParseResult.subcommand().commandSpec().name();
|
||||
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();
|
||||
QProcessMetaData process = qInstance.getProcess(processName);
|
||||
@ -386,7 +392,7 @@ public class QPicoCliImplementation
|
||||
catch(Exception e)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ class QPicoCliImplementationTest
|
||||
JSONObject processes = metaData.getJSONObject("processes");
|
||||
JSONObject greetProcess = processes.getJSONObject("greet");
|
||||
assertEquals("greet", greetProcess.getString("name"));
|
||||
// todo - need label assertEquals("Person", greetProcess.getString("label"));
|
||||
assertEquals("Greet", greetProcess.getString("label"));
|
||||
assertEquals("person", greetProcess.getString("tableName"));
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ package com.kingsrook.qqq.frontend.picocli;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
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.QCodeReference;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QCodeType;
|
||||
@ -168,7 +169,7 @@ public class TestUtils
|
||||
.addFunction(new QFunctionMetaData()
|
||||
.withName("prepare")
|
||||
.withCode(new QCodeReference()
|
||||
.withName("com.kingsrook.qqq.backend.core.interfaces.mock.MockFunctionBody")
|
||||
.withName(MockFunctionBody.class.getName())
|
||||
.withCodeType(QCodeType.JAVA)
|
||||
.withCodeUsage(QCodeUsage.FUNCTION)) // todo - needed, or implied in this context?
|
||||
.withInputData(new QFunctionInputMetaData()
|
||||
|
Reference in New Issue
Block a user