🕷 software projects

by ryan davis



sitemap

path_expander

pre-process command-line arguments expanding directories into files

Description

PathExpander helps pre-process command-line arguments expanding directories into their constituent files. It further helps by providing additional mechanisms to make specifying subsets easier with path subtraction and allowing for command-line arguments to be saved in a file.

NOTE: this is NOT an options processor. It is a path processor (basically everything else besides options). It does provide a mechanism for pre-filtering cmdline options, but not with the intent of actually processing them in PathExpander. Use OptionParser to deal with options either before or after passing ARGV through PathExpander.

Features & Problems

  • Processes command-line arguments.
  • Expands directories into files using custom globs.
  • Allows for negation of files.
  • Allows for use of files as persisted args.
  • Provides a .ignore mechanism for lightweight persistent exclusion.

Synopsis

1
2
3
4
5
6
7
8
9
10
11
class MyPathExpander < PathExpander
  MY_GLOB = "**/*.rb"

  def initialize args = ARGV
    super args, MY_GLOB
  end
end

MyPathExpander.new(ARGV, my_glob).process.each do |f|
  # do something with each file
end

Get The Code

If you just want to use path_expander, you can install it via RubyGems:
gem install path_expander
Fork me on GitHub If you want to hack on path_expander, clone it from GitHub:
git clone git://github.com/seattlerb/path_expander

Latest Activity