Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdw429s committed Jul 15, 2017
2 parents f1b7513 + edb63f0 commit 1987cfb
Show file tree
Hide file tree
Showing 366 changed files with 7,575 additions and 7,135 deletions.
4 changes: 2 additions & 2 deletions build/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ java.debug=true
#dependencies
dependencies.dir=${basedir}/lib
cfml.version=4.5.5.006
cfml.loader.version=1.4.7
cfml.loader.version=1.5.4
cfml.cli.version=${cfml.loader.version}.${cfml.version}
lucee.version=${cfml.version}
jre.version=1.8.0_102
launch4j.version=3.4
runwar.version=3.6.0-SNAPSHOT
runwar.version=3.6.1-SNAPSHOT

#build locations
build.type=localdev
Expand Down
4 changes: 2 additions & 2 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ External Dependencies:
<property name="distro.groupID" value="ortussolutions" />
<property name="distro.name" value="commandbox"/>
<!-- Special things happen when the version and stableVersion are the same value as that signifies a "stable" build. -->
<property name="commandbox.version" value="3.6.0"/>
<property name="commandbox.stableVersion" value="3.6.0"/>
<property name="commandbox.version" value="3.7.0"/>
<property name="commandbox.stableVersion" value="3.7.0"/>

<!-- Time Label -->
<tstamp prefix="start"/>
Expand Down
14 changes: 7 additions & 7 deletions src/cfml/Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ component{
// kick in an abort to exit shell, application timeout controls wirebox.
abort;
}

function onError( any exception, string eventName ) {

createObject( 'java', 'java.lang.System' ).setProperty( 'cfml.cli.exitCode', '1' );

// Try to log this to LogBox
try {
application.wireBox.getLogBox().getRootLogger().error( '#exception.message# #exception.detail ?: ''#', exception.stackTrace );
application.wireBox.getInstance( 'interceptorService' ).announceInterception( 'onException', { exception=exception } );
// If it fails no worries, LogBox just probably isn't loaded yet.
} catch ( Any e ) {}

// Give nicer message to user
var err = arguments.exception;
var CR = chr( 13 );
Expand Down Expand Up @@ -71,10 +71,10 @@ component{
systemOutput( '', true );
systemOutput( '#err.stacktrace#', true );

//writeDump(var=arguments.exception, output="console");
//writeDump(var=arguments.exception, output="console");

// Give them a chance to read it
sleep( 30000 );
}

}
}
130 changes: 96 additions & 34 deletions src/cfml/system/BaseCommand.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/
component accessors="true" singleton {

// DI
property name="CR";
property name="formatterUtil";
Expand All @@ -19,51 +19,53 @@ component accessors="true" singleton {
property name="wirebox";
property name="logger";
property name="parser";
property name="SystemSettings";

/**
* Constructor
*/
function init() {
var wirebox = application.wirebox;
variables.wirebox = application.wirebox;
variables.CR = wirebox.getInstance( "CR@constants" );
variables.formatterUtil = wirebox.getInstance( "Formatter" );
variables.fileSystemUtil = wirebox.getInstance( "FileSystem" );
variables.shell = wirebox.getInstance( "shell" );
variables.print = wirebox.getInstance( "PrintBuffer" );
variables.wirebox = wirebox;
variables.logger = wirebox.getLogBox().getLogger( this );
variables.parser = wirebox.getInstance( "Parser" );

variables.configService = wirebox.getInstance( "ConfigService" );
variables.SystemSettings = wirebox.getInstance( "SystemSettings" );

hasErrored = false;
return this;
}

// This method needs to be overridden by the concrete class.
function run() {
return 'This command CFC has not implemented a run() method.';
}
}

// Convenience method for getting stuff from WireBox
function getInstance( name, dsl, initArguments={}, targetObject='' ) {
return wirebox.getInstance( argumentCollection = arguments );
}

// Called prior to each execution to reset any state stored in the CFC
function reset() {
print.clear();
hasErrored = false;
}

// Get the result. This will be called if the run() method doesn't return anything
function getResult() {
return print.getResult();
}

// Returns the current working directory of the shell
function getCWD() {
return shell.pwd();
}

/**
* ask the user a question and wait for response
* @message.hint message to prompt the user with
Expand All @@ -75,18 +77,18 @@ component accessors="true" singleton {
print.toConsole();
return shell.ask( arguments.message, arguments.mask, arguments.defaultResponse );
}

/**
* Wait until the user's next keystroke
* @message.hint Message to display to the user such as "Press any key to continue."
**/
function waitForKey( message='' ) {
if( len( arguments.message ) ) {
print.toConsole();
print.toConsole();
}
return shell.waitForKey( arguments.message );
}

/**
* Ask the user a question looking for a yes/no response
* Accepts any boolean value, or "y".
Expand All @@ -96,7 +98,7 @@ component accessors="true" singleton {
print.toConsole();
return shell.confirm( arguments.message );
}

/**
* Run another command by name.
* This is deprecated in favor of command(), which escapes parameters for you.
Expand All @@ -105,58 +107,87 @@ component accessors="true" singleton {
function runCommand( required command, returnOutput=false ) {
return shell.callCommand( arguments.command, arguments.returnOutput );
}

/**
* Run another command by DSL.
* Run another command by DSL.
* @name.hint The name of the command to run.
**/
function command( required name ) {
return getinstance( name='CommandDSL', initArguments={ name : arguments.name } );
}

/**
* Create a directory watcher. Call its DSL to configure it.
**/
function watch() {
return getinstance( 'watcher' );
}

/**
* Return a new globber
**/
function globber( pattern='' ) {
var globber = wirebox.getInstance( 'Globber' );
if( pattern.len() ) {
globber.setPattern( arguments.pattern );
}
return globber;
}

/**
* Return a new PropertyFile instance
**/
function propertyFile( propertyFilePath='' ) {
var propertyFile = wirebox.getInstance( 'propertyFile@propertyFile' );
if( propertyFilePath.len() ) {
propertyFile.load( propertyFilePath );
}
return propertyFile;
}

/**
* Use if if your command wants to give controlled feedback to the user without raising
* an actual exception which comes with a messy stack trace.
* Use clearPrintBuffer to wipe out any output accrued in the print buffer.
*
* an actual exception which comes with a messy stack trace.
* Use clearPrintBuffer to wipe out any output accrued in the print buffer.
*
* return error( "We're sorry, but happy hour ended 20 minutes ago." );
*
*
* @message.hint The error message to display
* @clearPrintBuffer.hint Wipe out the print buffer or not, it does not by default
**/
function error( required message, detail='', clearPrintBuffer=false ) {
setExitCode( 1 );
hasErrored = true;
if( arguments.clearPrintBuffer ) {
// Wipe
// Wipe
print.clear();
} else {
// Distance ourselves from whatever other output the command may have given so far.
print.line();
}
throw( message=arguments.message, detail=arguments.detail, type="commandException");

}

/**
* Tells you if the error() method has been called on this command.
* Tells you if the error() method has been called on this command.
**/
function hasError() {
return hasErrored;
}

/**
* Sets the OS exit code
* Sets the OS exit code
**/
function setExitCode( required string exitCode ) {
if( arguments.exitCode != 0 ) {
hasErrored = true;
}
return shell.setExitCode( arguments.exitCode );
}

/**
* This will open a file or folder externally in the default editor for the user.
* This will open a file or folder externally in the default editor for the user.
* Useful for opening a new file for editing that was just created.
**/
function openPath( path ) {
Expand All @@ -165,15 +196,46 @@ component accessors="true" singleton {
.params( arguments.path )
.run();
}

/**
* This will open a URL in the user's browser
* This will open a URL in the user's browser
**/
function openURL( theURL ) {
// Defer to "browse" command.
command( "browse" )
.params( arguments.theURL )
.run();
.run();
}

/**
* Retrieve a Java System property or env value by name.
*
* @key The name of the setting to look up.
* @defaultValue The default value to use if the key does not exist in the system properties
*/
function getSystemSetting( required string key, defaultValue ) {
return systemSettings.getSystemSetting( argumentCollection=arguments );
}

/**
* Retrieve a Java System property by name.
*
* @key The name of the setting to look up.
* @defaultValue The default value to use if the key does not exist in the system properties
*/
function getSystemProperty( required string key, defaultValue ) {
return systemSettings.getSystemProperty( argumentCollection=arguments );
}

}

/**
* Retrieve an env value by name.
*
* @key The name of the setting to look up.
* @defaultValue The default value to use if the key does not exist in the env
*/
function getEnv( required string key, defaultValue ) {
return systemSettings.getEnv( argumentCollection=arguments );
}


}
15 changes: 15 additions & 0 deletions src/cfml/system/BaseTask.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
*********************************************************************************
* Copyright Since 2014 CommandBox by Ortus Solutions, Corp
* www.coldbox.org | www.ortussolutions.com
********************************************************************************
* @author Brad Wood, Luis Majano, Denny Valliant
*
* I am the base task implementation. An abstract class if you will.
*
*/
component accessors="true" extends='commandbox.system.BaseCommand' {

// For now, tasks just do everything commands do

}
Loading

0 comments on commit 1987cfb

Please sign in to comment.