org.wildfly.extras.creaper.commands.foundation.online
Class CliFile

java.lang.Object
  extended by org.wildfly.extras.creaper.commands.foundation.online.CliFile
All Implemented Interfaces:
Command, OnlineCommand

public final class CliFile
extends Object
implements OnlineCommand

Apply a list of CLI operations (a CLI script) read from a file. The file is treated as UTF-8 text. If you already have the script text as a String, use the CliScript command.

See the documentation of CliScript for more information about special handling of certain operations.


Field Summary
 
Fields inherited from interface org.wildfly.extras.creaper.core.online.OnlineCommand
NOOP
 
Constructor Summary
CliFile(Class clazz)
          Apply a CLI script from the classpath.
CliFile(Class resourceLoader, String path)
          Apply a CLI script from the classpath.
CliFile(File file)
          Apply a CLI script from the filesystem (file).
 
Method Summary
 void apply(OnlineCommandContext ctx)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CliFile

public CliFile(File file)
Apply a CLI script from the filesystem (file).

Parameters:
file - an existing file on the filesystem
Throws:
IllegalArgumentException - if file is null or doesn't exist

CliFile

public CliFile(Class clazz)
Apply a CLI script from the classpath. The script must be stored in a file with the same name as the clazz and have the .cli extension. On the classpath, the script file must live along the class file.

Parameters:
clazz - the class that will be used for loading the script and also for discovering its name
Throws:
IllegalArgumentException - if the clazz is null

CliFile

public CliFile(Class resourceLoader,
               String path)
Apply a CLI script from the classpath. The script is loaded from classpath at path. The resource will be loaded by the resourceLoader class (Class.getResourceAsStream(String)).

Parameters:
resourceLoader - class that will be used to load the script from classpath
path - path to the script on classpath (absolute or relative to resourceLoader)
Throws:
IllegalArgumentException - if the resourceLoader or path is null
Method Detail

apply

public void apply(OnlineCommandContext ctx)
           throws IOException,
                  CliException,
                  CommandFailedException
Specified by:
apply in interface OnlineCommand
Throws:
IOException
CliException
CommandFailedException

toString

public String toString()
Specified by:
toString in interface OnlineCommand
Overrides:
toString in class Object


Copyright © 2020. All rights reserved.