BaseTask Super Class
Much of the functionality available to you in task runners comes via inheritance from the super class that all tasks extend. Even if you don't have an extends attribute, CommandBox uses the power of WireBox virtual inheritance to apply the super class.
1
─┬ commandbox.system.BaseCommand - Base task for all custom commands
2
└─┬ commandbox.system.BaseTask - base task for all task runners
3
└── task - Your custom task runner
Copied!
The see most up-to-date list of all methods and properties from the base classes, check the API docs:
CommandBox Core API Docs
BaseTask
CommandBox Core API Docs
BaseCommand

Properties

Here is an over view of common methods available to every task from the base classes

Methods

Here is an over view of common methods available to every task from the base classes
1
// Returns the AsyncManager class
2
async()
3
4
// Convenience method for getting stuff from WireBox
5
getInstance( name, dsl, initArguments={}, targetObject='' )
6
7
// Retuns current exit code
8
getExitCode()
9
10
// Sets exit code to be returned when task completes
11
setExitCode( required numeric exitCode )
12
13
// Returns the current working directory of the shell
14
getCWD()
15
16
// ask the user a question and wait for response
17
ask( message, string mask='', string defaultResponse='', keepHistory=false, highlight=true, complete=false )
18
19
// Wait until the user's next keystroke amd return the char code
20
waitForKey( message='' )
21
22
// Ask the user a question looking for a yes/no response and return a boolean
23
confirm( required message )
24
25
// Intiator for multiselect DSL. (Check "task interactiviy" page in docs)
26
multiSelect()
27
28
// Run another command by name.
29
runCommand( required command, returnOutput=false )
30
31
// Intiator for Command DSL. (Check "running other commands" page in docs)
32
command( required name )
33
34
// Intiator for directory watcher DSL. (Check "Watchers" page in docs)
35
watch()
36
37
// This resolves an absolute or relative path using the rules of the operating system and CLI.
38
resolvePath( required string path, basePath=shell.pwd() )
39
40
// Intiator for globber DSL (check "Using file globs" page in docs)
41
globber( pattern='' )
42
43
// Intiator for PropertyFile DSL (check "property files" page in docs)
44
propertyFile( propertyFilePath='' )
45
46
// Report error in your task. Raises an exception that will not print the stack trace
47
error( required message, detail='', clearPrintBuffer=false, exitCode=1 )
48
49
// Returns true if current exit code is not 0.
50
hasError()
51
52
// Open a file or folder externally in the default editor for the user.
53
openPath( path )
54
55
// Open a URL in the user's browser
56
openURL( theURL, browser='' )
57
58
// Set a CommandBox environment variable
59
setSystemSetting( required string key, string value )
60
61
// Retrieve a Java System property or env value by name.
62
getSystemSetting( required string key, defaultValue )
63
64
// Retrieve a Java System property by name.
65
getSystemProperty( required string key, defaultValue )
66
67
// Retrieve an env value by name.
68
getEnv( required string key, defaultValue )
69
70
// Call this method periodically in a long-running task to check and see
71
// if the user has hit Ctrl-C. This method will throw an UserInterruptException
72
// which you should not catch. It will unroll the stack all the way back to the shell
73
checkInterrupted( thisThread=variables.thisThread )
74
75
// Loads up Java classes into the class loader that loaded the CLI for immediate use.
76
// (Check "Loading Ad hoc Jars" page in docs)
77
classLoad( paths )
78
79
// Get the current java.lang.Thread object
80
getCurrentThread()
81
82
// Get the current thread name
83
getThreadName()
84
Copied!
Last modified 5mo ago
Copy link