foundeo / toscript

Converts Tag based CFML to CFML Script
GNU General Public License v3.0
20 stars 9 forks source link

Allow for file globbing in paths #27

Open bdw429s opened 7 years ago

bdw429s commented 7 years ago

So it would be super cool to allow for file globbing (especially for the CLI command) so I could say to convert folders like /models/**.cfc, **.cfc, or /handlers/oneSpecificPackage/*.cfc.

I've already got a library for this that I use in CommandBox that you can just pull in as a dependency.
https://www.forgebox.io/view/globber

It's a transient with a nice fluent DSL to get directory listings for you and even handle FP-style iterations over the results.

wirebox.getInstance( 'globber' )
    .setPattern( 'C:/myFolder/*.md' )
    .apply( function( path ) {
        fileDelete( path );
    } );

It's also worth noting that CommandBox 3.7 will have native support for globbing parameters in commands by just setting the parameter type, but it's still in beta.

bdw429s commented 7 years ago

I forgot to mention-- you can skip the fuent API and use the PathPatternMatcher class directly to get fancy with whitelists and blacklists: https://github.com/Ortus-Solutions/globber/blob/master/models/PathPatternMatcher.cfc

Then you could do something like:

CommandBox> cfscriptme sourcePath=./ exclude=coldbox/**,examples/*Tag.cfc
pfreitag commented 7 years ago

Thanks I will look into this.