Module: Fig
- Defined in:
- lib/fig/windows.rb,
lib/fig/os.rb,
lib/fig/parser.rb,
lib/fig/options.rb,
lib/fig/package.rb,
lib/fig/repository.rb,
lib/fig/environment.rb
Overview
I don’t know how to set environment variables so that a sub-shell will be able to use them. Therefore, I’m punting, and creating a batch script on the fly to run a user supplied command.
Defined Under Namespace
Classes: Archive, Command, Configuration, Environment, Include, Install, NotFoundException, OS, Package, Parser, Path, Publish, Repository, Resource, Retrieve, Set, Windows
Instance Method Summary collapse
Instance Method Details
#parse_descriptor(descriptor) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fig/options.rb', line 5 def parse_descriptor(descriptor) # todo should use treetop for these: package_name = descriptor =~ /^([^:\/]+)/ ? $1 : nil config_name = descriptor =~ /:([^:\/]+)/ ? $1 : nil version_name = descriptor =~ /\/([^:\/]+)/ ? $1 : nil return package_name, config_name, version_name end |
#parse_options(argv) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/fig/options.rb', line 13 def (argv) = {} parser = OptionParser.new do |opts| opts. = "Usage: fig [--debug] [--update] [--config <config>] [--get <var> | --list | <package> | - <command>]" opts.on('-?', '-h','--help','display this help text') do puts opts exit 1 end [:debug] = false opts.on('-d', '--debug', 'print debug info') { [:debug] = true } [:update] = false opts.on('-u', '--update', 'check remote repository for updates') { [:update] = true; [:retrieve] = true } [:update_if_missing] = false opts.on('-m', '--update-if-missing', 'check for updates only if package is missing locally') { [:update_if_missing] = true; [:retrieve] = true } [:config] = "default" opts.on('-c', '--config CFG', 'name of configuration to apply') { |config| [:config] = config } [:echo] = nil opts.on('-g', '--get VAR', 'print value of environment variable') { |echo| [:echo] = echo } [:publish] = nil opts.on('--publish PKG', 'install package in local and remote repositories') { |publish| [:publish] = publish } [:publish_local] = nil opts.on('--publish-local PKG', 'install package in local repositorie only') { |publish_local| [:publish_local] = publish_local } [:force] = nil opts.on('--force', 'force overwriting of an existing remote package version') { |force| [:force] = force } [:resources] =[] opts.on('--resource PATH', 'resource to include in package (when using --publish)') do |path| [:resources] << Resource.new(path) end [:archives] =[] opts.on('--archive PATH', 'archive to include in package (when using --publish)') do |path| [:archives] << Archive.new(path) end [:login] = false opts.on('-l', '--login', 'login into the FTP server as a non-anonymous user') { [:login] = true } [:list] = false opts.on('--list', 'list packages in local repository') { [:list] = true } [:list_remote] = false opts.on('--list-remote', 'list packages in remote repository') { [:list_remote] = true } [:list_configs] = [] opts.on('--list-configs PKG', 'list configurations in package') { |descriptor| [:list_configs] << descriptor } [:cleans] = [] opts.on('--clean PKG', 'remove package from local repository') { |descriptor| [:cleans] << descriptor } [:modifiers] = [] opts.on('-i', '--include PKG', 'include package in environment') do |descriptor| package_name, config_name, version_name = parse_descriptor(descriptor) [:modifiers] << Include.new(package_name, config_name, version_name) end opts.on('-s', '--set VAR=VAL', 'set environment variable') do |var_val| var, val = var_val.split('=') [:modifiers] << Set.new(var, val) end opts.on('-p', '--append VAR=VAL', 'append environment variable') do |var_val| var, val = var_val.split('=') [:modifiers] << Path.new(var, val) end [:input] = nil opts.on('--file FILE', 'fig file to read (use - for stdin)') { |path| [:input] = path } opts.on('--no-file', 'ignore package.fig file in current directory') { |path| [:input] = :none } [:home] = ENV['FIG_HOME'] || File.("~/.fighome") end parser.parse!(argv) return , argv end |