Class BaseCliCommand
java.lang.Object
com.e1c.g5.v8.dt.cli.api.components.BaseCliCommand
- All Implemented Interfaces:
ICliCommand
,ICliSessionConsumer
,Consumer<ICliSession>
- Direct Known Subclasses:
BaseProjectCmds
,FormatBslFilesCmd
,ImportConfigurationFilesCmd
,PlatformSupportCommand
Base implementation of a CLI command provider. Provides a number of convenient helpers to create standard commands
that works with the EDT platform.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ICliSession cliSession) protected <R> R
backgroundOperation
(String operationName, IDtProject dtProject, ProjectPipelineJob targetStage, Callable<R> callable) Executes logic within background-priority orchestrated operation (seeIWorkspaceOrchestrator
protected <V> V
exclusiveOperation
(String operationName, IDtProject dtProject, ProjectPipelineJob targetJob, Callable<V> callable) Executes logic within exclusive-priority orchestrated operation (seeIWorkspaceOrchestrator
protected Collection<File>
findProjectsRecursively
(Path[] projectDirs) Finds project files recursively by given collection of directoriesprotected CliCommandContext
Gets standard service context of a command.protected Path
Returns the current session's working directory.getProjectsRecursively
(Path path) Gets all Eclipse .project files from a provided folder, with recursive search.protected void
Logs an error with a specified messageprotected void
Logs an error with a specified messageprotected IDtProject
startDtProject
(Path projectDir) Starts DT project that is pointed by a specified path.protected boolean
waitUntilStarted
(IDtProject project, Duration waitDuration) Waits until a specifiedIDtProject
is started (all service contexts are up and running)protected boolean
waitUntilStarted
(org.eclipse.core.resources.IProject project, Duration waitDuration) Waits until a specifiedIProject
is started (all service contexts are up and running)
-
Field Details
-
DT_PROJECT_STARTUP_DURATION
-
-
Constructor Details
-
BaseCliCommand
public BaseCliCommand()
-
-
Method Details
-
getProjectsRecursively
Gets all Eclipse .project files from a provided folder, with recursive search.- Parameters:
path
- The path to a folder which may contain projects. Cannot benull
- Returns:
- A collection of found projects. Never
null
but may be empty
-
accept
- Specified by:
accept
in interfaceConsumer<ICliSession>
-
getCurrentWorkDir
Returns the current session's working directory. You should resolve all relative paths against this directory (except for workspace relative paths). This is not the workspace directory. Initially this value is the directory the 1C:EDT CLI process is executed from. But the user (or other commands) can change it later for each session separately either by calling the builtincd
command, or by changing the_cwd
session variable. Because of this you should not rely on the JVM process working directory (System.getProperty("user.dir")
orFile.getAbsolutePath()
or other methods like this).- Returns:
- the current working directory of the current session. Never
null
. - See Also:
-
backgroundOperation
protected <R> R backgroundOperation(String operationName, IDtProject dtProject, ProjectPipelineJob targetStage, Callable<R> callable) Executes logic within background-priority orchestrated operation (seeIWorkspaceOrchestrator
- Type Parameters:
R
- Type of return value- Parameters:
operationName
- The name of an operation to be executed. Cannot benull
dtProject
- Target project to execute the operation on. Cannot benull
targetStage
- Target stage of the project's pipeline. Cannot benull
callable
- Callable to execute. Cannot benull
- Returns:
- Result of the operation execution. Depends on the provided
Callable
. May benull
-
exclusiveOperation
protected <V> V exclusiveOperation(String operationName, IDtProject dtProject, ProjectPipelineJob targetJob, Callable<V> callable) Executes logic within exclusive-priority orchestrated operation (seeIWorkspaceOrchestrator
- Type Parameters:
R
- Type of return value- Parameters:
operationName
- The name of an operation to be executed. Cannot benull
dtProject
- Target project to execute the operation on. Cannot benull
targetStage
- Target stage of the project's pipeline. Cannot benull
callable
- Callable to execute. Cannot benull
- Returns:
- Result of the operation execution. Depends on the provided
Callable
. May benull
-
findProjectsRecursively
Finds project files recursively by given collection of directories- Parameters:
projectDirs
- the project directories- Returns:
- the collection of
.../ProjectName/.project
files, cannot returnnull
.
-
getContext
Gets standard service context of a command.- Returns:
- A command context. May not be
null
in case of proper command initialization
-
startDtProject
Starts DT project that is pointed by a specified path. Do nothing if the project is already started to allow easy chaining of commands This method waits when DT project has started but it doesn't wait build completion Use workspace orchestration operation to do the job on correct lifecycle stage- Parameters:
projectDir
- the project directory, cannot benull
.- Returns:
- the started DT project, cannot return
null
. May throw exception in case of errors during the project start
-
waitUntilStarted
Waits until a specifiedIDtProject
is started (all service contexts are up and running)- Parameters:
project
- The project to wait start for. Cannot benull
waitDuration
- Wait duration time. Cannot benull
- Returns:
- True if the project is started before the timeout
-
waitUntilStarted
protected boolean waitUntilStarted(org.eclipse.core.resources.IProject project, Duration waitDuration) Waits until a specifiedIProject
is started (all service contexts are up and running)- Parameters:
project
- The project to wait start for. Cannot benull
waitDuration
- Wait duration time. Cannot benull
- Returns:
- True if the project is started before the timeout
-
logError
Logs an error with a specified message- Parameters:
message
- Message to log as en error. Cannot benull
-
logError
Logs an error with a specified message- Parameters:
message
- Message to log as en error. Cannot benull
cause
- Throwable that caused/indicates error. Cannot benull
-