fig 0.1.39-java → 0.1.41-java

Sign up to get free protection for your applications and to get access to all the features.
data/Changes ADDED
@@ -0,0 +1,45 @@
1
+ v0.1.41
2
+
3
+ - Release cleanup
4
+
5
+ v0.1.40
6
+
7
+ - Supports configuration via rc files in JSON format. These can be (in
8
+ ascending order of priority of values):
9
+ - in the repository under "_meta/figrc"
10
+ - in your home directory in ".figrc"
11
+ - specified on the command-line via the "--figrc" option
12
+
13
+ Note that values from all the above locations will be merged into a
14
+ single, net application configuration. E.g. if
15
+ <repository>/_meta/figrc contains
16
+
17
+ {"a" => 5, "b" => 7"}
18
+
19
+ and ~/.figrc contains
20
+
21
+ {"a" => 37}
22
+
23
+ then Fig will see a value for "a" of 37 and a value for "b" of 7.
24
+
25
+ Processing of ~/.figrc can be suppressed via the "--no-figrc" option.
26
+
27
+ - Supports logging via log4r. Configure via "log configuration" in the rc
28
+ files or via the "--log-config" and "--log-level" command-line options.
29
+ The configuration files must be in XML or YAML format in a way supported
30
+ by log4r and contain configuration for a "fig" logger. The "--log-level"
31
+ will override any value found in the configuration files.
32
+
33
+ - Added additional messages about activity including file download source
34
+ and destination. Try "--log-level debug". Suggestions about changes to
35
+ levels that are supported, which levels messages are emitted at, and any
36
+ additional desired logging are welcome.
37
+
38
+ - Supports "-v/--version" to emit the Fig version.
39
+
40
+ - No longer silently does nothing when no arguments are specified.
41
+
42
+ - Start of support for restricting URLs in package.fig files via a URL
43
+ whitelist; not complete yet and will likely change.
44
+
45
+ - RSpec usage has been upgraded to v2.
data/LICENSE CHANGED
@@ -11,8 +11,8 @@ modification, are permitted provided that the following conditions are met:
11
11
  notice, this list of conditions and the following disclaimer in the
12
12
  documentation and/or other materials provided with the distribution.
13
13
 
14
- * The names of the contributors may not be used to endorse or promote
15
- products derived from this software without specific prior written
14
+ * The names of the contributors may not be used to endorse or promote
15
+ products derived from this software without specific prior written
16
16
  permission.
17
17
 
18
18
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
data/README.md CHANGED
@@ -1,94 +1,116 @@
1
1
  Description
2
2
  ===========
3
3
 
4
- Fig is a utility for configuring environments and managing dependencies across a team of developers. Fig takes a list of packages and a shell command to run, creates an environment that includes those packages, then executes the shell command in that environment. The caller's environment is not affected.
5
-
6
- An "environment" in fig is just a set of environment variables. A "package" is a collection of files, plus some metadata describing what environment variables should be modified when the package is included.
7
-
8
- Developers can use package files to specify the list of dependencies to use for different tasks. This file will typically be versioned along with the rest of the source files, ensuring that all developers on a team are using the same environemnts.
9
-
10
- Packages exist in two places: a "local" repository in the user's home directory, and a "remote" repository on a shared server. Fig will automatically download packages from the remote repository and install them in the local repository as needed.
11
-
12
- Fig is similar to a lot of other package/dependency managment tools. In particular, it steals a lot of ideas from Apache Ivy and Debian APT. However, unlike Ivy, fig is meant to be lightweight (no XML, no JVM startup time), language agnostic (Java doesn't get preferential treatment), and work with executables as well as libraries. And unlike APT, fig is cross platform and project-oriented.
4
+ Fig is a utility for configuring environments and managing dependencies across a team of developers.
5
+
6
+ An "environment" in fig is a set of environment variables. A "package" is a
7
+ collection of files, along with some metadata describing which environment variables
8
+ should be modified when the package is included. For instance, each dependency
9
+ may prepend its corresponding jar to CLASSPATH. The metadata may also list
10
+ that package's lower-level Fig package dependencies.
11
+
12
+ Fig recursively builds an environment consisting of package dependencies
13
+ (typically specified via command-line options or a package.fig file), each of
14
+ which as noted above may have its own dependencies, and optionally executes a
15
+ shell command in that environment. The caller's environment is not affected.
16
+
17
+ Developers can use package.fig files to specify the list of dependencies to use for
18
+ different tasks. This file will typically be versioned along with the rest of
19
+ the source files, ensuring that all developers on a team are using the same
20
+ environemnts.
21
+
22
+ Packages exist in two places: a "local" repository cache in the user's home
23
+ directory--also called the fig-home--and a "remote" repository on a shared
24
+ server. Fig will automatically download packages from the remote repository and
25
+ install them in the fig-home as needed. Fig does not contact the remote
26
+ repository unless it needs to. The fig-home is $HOME/.fighome, but may be
27
+ changed by setting the $FIG_HOME environment variable.
28
+
29
+ Fig is similar to a lot of other package/dependency-management tools. In
30
+ particular, it steals a lot of ideas from Apache Ivy and Debian APT. However,
31
+ unlike Ivy, fig is meant to be lightweight (no XML, no JVM startup time),
32
+ language agnostic (Java doesn't get preferential treatment), and work with
33
+ executables as well as libraries. And unlike APT, fig is cross platform and
34
+ project-oriented.
13
35
 
14
36
  Installation
15
37
  ============
16
38
 
17
- Fig can be installed via rubygems. The gems are hosted at [Gemcutter](http://gemcutter.org), so you'll need to set that up first:
18
-
19
- $ gem install gemcutter
20
- $ gem tumble
21
-
22
- Fig also depends on a third-party library named
23
- [libarchive](http://libarchive.rubyforge.org/). Libarchive is easily available
24
- via most package management systems on Linux, FreeBSD, and OS X. Libarchive
25
- versions greater than 2.6.0 are preferred. If you are on Windows (not Cygwin Ruby), the gem will
26
- install the libarchive binaries for you.
27
-
28
- [Linux - Debian / Ubuntu]
29
- apt-get libarchive-dev
30
-
31
- [Linux - Red Hat / CentOS]
32
- yum install libarchive-devel
39
+ $ gem install fig
33
40
 
34
- [OS X - MacPorts]
35
- port install libarchive
41
+ Or, if running Ruby 1.8.x...
36
42
 
37
- Then you can install fig:
38
-
39
- $ gem install fig
43
+ $ gem install fig18
40
44
 
41
45
  Usage
42
46
  =====
43
47
 
44
- Fig recognizes the following options (not all are implemented yet):
48
+ Fig recognizes the following options:
45
49
 
46
50
  ### Flags ###
47
51
 
48
- -d, --debug Print debug info
49
- --force Download/install packages from remote repository, even if up-to-date
50
- -u, --update Download/install packages from remote repository, if out-of-date
51
- -m, --update-if-missing Download/install packages from remote repository, if not already installed
52
- -l, --login Authenticate with remote server using username/password (default is anonymous)
53
-
54
- If the `--login` option is supplied, fig will look for credentials. If
55
- environment variables `FIG_REMOTE_USER` and/or `FIG_REMOTE_PASSWORD` are
56
- defined, fig will use them instead of prompting the user. If ~/.netrc exists,
57
- with an entry corresponding to the host parsed from `FIG_REMOTE_URL`, that
58
- entry will take precedence over `FIG_REMOTE_USER` and `FIG_REMOTE_PASSWORD`.
59
- If sufficient credentials are still not found, fig will prompt for whatever is
60
- still missing, and use the accumulated credentials to authenticate against the
61
- remote server. Even if both environment variables are defined, fig will only
62
- use them if `--login` is given.
63
-
64
- ### Environment Modifiers ###
65
-
66
- The following otpions modify the environment generated by fig:
67
-
68
- -i, --include DESCRIPTOR Include package in environment (recursive)
69
- -p, --append VAR=VALUE Append value to environment variable using platform-specific separator
70
- -s, --set VAR=VALUE Set environment variable
71
-
72
- ### Environment Commands ###
73
-
74
- The following commands will be run in the environment created by fig:
75
-
76
- -g, --get VARIABLE Get value of environment variable
77
- -- COMMAND [ARGS...] Execute arbitrary shell command
78
-
79
- ### Other Commands ###
80
-
81
- Fig also supports the following options, which don't require a fig environment. Any modifiers will be ignored:
82
-
83
- -?, -h, --help Display this help text
84
- --publish Upload package to the remote repository (also installs in local repository)
85
- --publish-local Install package in local repository only
86
- --list List packages in local repository
87
- --list-remote List packages in remote repository
88
-
89
- When using the `--list-remote` command against an FTP server, fig uses a pool of FTP sessions to improve
90
- performance. By default it opens 16 connections, but that number can be overridden by setting the
91
- `FIG_FTP_THREADS` environment variable.
52
+ -?, -h, --help display this help text
53
+ -v, --version Print fig version
54
+ -p, --append VAR=VAL append (actually, prepend) VAL to environment var VAR, delimited by separator
55
+ --archive FULLPATH include FULLPATH archive in package (when using --publish)
56
+ --clean PKG remove package from $FIG_HOME
57
+ -c, --config CFG apply configuration CFG, default is 'default'
58
+ -d, --debug print debug info
59
+ --file FILE read fig file FILE. Use '-' for stdin. See also --no-file
60
+ --force force-overwrite existing version of a package to the remote repo
61
+ -g, --get VAR print value of environment variable VAR
62
+ -i, --include PKG include PKG (with any variable prepends) in environment
63
+ --list list packages in $FIG_HOME
64
+ --list-configs PKG list configurations in package
65
+ --list-remote list packages in remote repo
66
+ -l, --login login to remote repo as a non-anonymous user
67
+ --no-file ignore package.fig file in current directory
68
+ --publish PKG install PKG in $FIG_HOME and in remote repo
69
+ --publish-local PKG install package only in $FIG_HOME
70
+ --resource FULLPATH include FULLPATH resource in package (when using --publish)
71
+ -s, --set VAR=VAL set environment variable VAR to VAL
72
+ -u, --update check remote repo for updates and download to $FIG_HOME as necessary
73
+ -m, --update-if-missing check remote repo for updates only if package missing from $FIG_HOME
74
+ --figrc PATH use PATH file as .rc file for Fig
75
+ --no-figrc ignore ~/.figrc
76
+ --log-config PATH use PATH file as configuration for Log4r
77
+ --log-level LEVEL set logging level to LEVEL
78
+ (off, fatal, error, warn, info, debug, all)
79
+
80
+ -- end of fig options; everything following is a command to run in the fig environment.
81
+
82
+ Some of these options may also be expressed as statements in a package.fig file. For instance,
83
+ `--append`, `--archive`, `--resource`, `include`.
84
+
85
+ One point of frequent confusion revolves around which statements are concerned with publishing packages, and
86
+ which are for downloading packages and otherwise modifying the Fig environment. The same Fig file
87
+ can contain both publish (e.g., `append`, `resource`) and download (e.g., `include`) statements,
88
+ but you may not want to use the same
89
+ dependency file for both publishing a package and specifying that same package's dependencies,
90
+ since for example its "build-time" dependencies may differ from its "include-time" dependencies.
91
+ Multiple config sections may be helpful in organizing these concerns.
92
+
93
+ ### Environment Variables Influencing Fig's Behavior ###
94
+
95
+ `FIG_FTP_THREADS` Optional - Size of FTP session pool. Defaults to 16.
96
+ `FIG_HOME` Optional - Location of local repo cache. Defaults to $HOME/.fighome.
97
+ `FIG_REMOTE_LOGIN` Required for --login, unless $HOME/.netrc is configured.
98
+ `FIG_REMOTE_URL` Require for operations involving the remote repository.
99
+ `FIG_REMOTE_USER` Required for --login, unless $HOME/.netrc is configured.
100
+
101
+ [--list-remote] When using the `--list-remote` command against an FTP server, fig uses a pool of FTP sessions to improve
102
+ performance. By default it opens 16 connections, but that number can be overridden by setting the
103
+ `FIG_FTP_THREADS` environment variable.
104
+
105
+ [--login] If the `--login` option is supplied, fig will look for credentials. If
106
+ environment variables `FIG_REMOTE_USER` and/or `FIG_REMOTE_PASSWORD` are
107
+ defined, fig will use them instead of prompting the user. If ~/.netrc exists,
108
+ with an entry corresponding to the host parsed from `FIG_REMOTE_URL`, that
109
+ entry will take precedence over `FIG_REMOTE_USER` and `FIG_REMOTE_PASSWORD`.
110
+ If sufficient credentials are still not found, fig will prompt for whatever is
111
+ still missing, and use the accumulated credentials to authenticate against the
112
+ remote server. Even if both environment variables are defined, fig will only
113
+ use them if `--login` is given.
92
114
 
93
115
  Examples
94
116
  ========
@@ -101,43 +123,51 @@ Fig lets you configure environments three different ways:
101
123
 
102
124
  ### Command Line ###
103
125
 
104
- So to get started, let's trying defining an environment variable via the command line and executing a command in the newenvironment. We'll set the "GREETING" variable to "Hello", then run a command that uses that variable:
126
+ To get started, let's define an environment variable via the command line and
127
+ execute a command in the new environment. We'll set the "GREETING" variable to
128
+ "Hello", then run a command that uses that variable:
105
129
 
106
- $ fig -s GREETING=Hello -- echo "\$GREETING, World"
130
+ $ fig -s GREETING=Hello -- echo '$GREETING, World'
107
131
  Hello, World
108
132
 
109
- Note that you need to put a slash before the dollar sign, otherwise the shell will evaluate the environment variable before it ever gets to fig.
110
-
111
133
  Also note that when running fig, the original environment isn't affected:
112
134
 
113
135
  $ echo $GREETING
114
136
  <nothing>
115
137
 
116
- Fig also lets you append environment variables, using the system-specified path separator (e.g. colon on unix, semicolon on windows). This is useful for adding directories to the PATH, LD_LIBRARY_PATH, CLASSPATH, etc. For example, let's create a "bin" directory, add a shell script to it, then include it in the PATH:
138
+ Fig also lets you append environment variables using the system-specified path separator (e.g. colon on unix, semicolon on windows). This is useful for adding directories to the PATH, LD_LIBRARY_PATH, CLASSPATH, etc. For example, let's create a "bin" directory, add a shell script to it, then include it in the PATH:
117
139
 
118
140
  $ mkdir bin
119
- $ echo "echo \$GREETING, World" > bin/hello
141
+ $ echo 'echo $GREETING, World' > bin/hello
120
142
  $ chmod +x bin/hello
121
143
  $ fig -s GREETING=Hello -p PATH=bin -- hello
122
144
  Hello, World
123
145
 
124
146
  ### Fig Files ###
125
147
 
126
- You can also specify environment modifiers in files. Fig looks for a file called "package.fig" in the current directory, and automatically processes it. So we can implement the previous example by creating a "package.fig" file that looks like:
127
-
148
+ You can also specify environment modifiers in files. Fig looks for a file called "package.fig" in the current directory and automatically processes it.
149
+ This "package.fig" file implements the previous example:
150
+
128
151
  config default
129
152
  set GREETING=Hello
130
153
  append PATH=@/bin
131
154
  end
132
-
133
- The '@' symbol represents the directory that the "package.fig" file is in (this example would still work if we just used "bin", but later on when we publish our project to the shared repository we'll definitely need the '@'). Then we can just run:
155
+
156
+ Then we can just run:
134
157
 
135
158
  $ fig -- hello
136
159
  Hello, World
137
160
 
138
- A single fig file can have multiple configurations:
161
+ NOTE: The '@' symbol in a given package.fig file (or in a published dependency's .fig
162
+ file) represents the full path to that file's directory. The
163
+ above example would
164
+ still work if we just used "bin", but later on when we publish our project to
165
+ the shared repository we'll definitely need the '@', since the project directories will
166
+ live in the fig-home rather than under our current directory).
167
+
168
+ A single fig file may have multiple configurations:
139
169
 
140
- config default
170
+ config default
141
171
  set GREETING=Hello
142
172
  append PATH=@/bin
143
173
  end
@@ -147,14 +177,30 @@ A single fig file can have multiple configurations:
147
177
  append PATH=@/bin
148
178
  end
149
179
 
180
+ ### Config Sections ###
181
+
150
182
  Configurations other than "default" can be specified using the "-c" option:
151
183
 
152
184
  $ fig -c french -- hello
153
185
  Bonjour, World
154
-
186
+
187
+ A config section can be included in another config section:
188
+
189
+ config default
190
+ include :spanish
191
+ end
192
+
193
+ config spanish
194
+ set GREETING="Buenas Dias"
195
+ append PATH=@/bin
196
+ end
197
+
155
198
  ### Packages ###
156
199
 
157
- Now let's say we want to share our little script with the rest of the team by bundling it into a package. The first thing we need to do is specify the location of the remote repository by defining the `FIG_REMOTE_URL` environment variable. If you just want to play around with fig, you can have it point to localhost:
200
+ Let's share our little script with the rest of the team by bundling it into a
201
+ package and publishing it. First, point the `FIG_REMOTE_URL` environment
202
+ variable to the remote repository. If you just want to play around with fig,
203
+ you can have it point to localhost:
158
204
 
159
205
  $ export FIG_REMOTE_URL=ssh://localhost$(pwd)/remote
160
206
 
@@ -164,51 +210,59 @@ Before we publish our package, we'll need to tell fig which files we want to inc
164
210
 
165
211
  config default...
166
212
 
167
- Now we can share the package with the rest of the team by using the "--publish" option:
213
+ Now we can share the package with the rest of the team by using the `--publish` option:
168
214
 
169
215
  $ fig --publish hello/1.0.0
170
216
 
171
- The "hello/1.0.0" string represents the name of the package and the version number. Once the package has been published, we can include it in other environments by using the "-i" or "--include" option (I'm going to move the "package.fig" file out of the way first, so that fig doesn't automatically process it.):
217
+ Once the package has been published, we can include it in other environments
218
+ with the `-i` or `--include` option. (For the purpose of this example, let's
219
+ first move the "package.fig" file out of the way, so that it doesn't confuse
220
+ fig or us.) The "hello/1.0.0" string represents the name of the package and the
221
+ version number.
172
222
 
173
223
  $ mv package.fig package.bak
174
224
  $ fig -u -i hello/1.0.0 -- hello
175
225
  ...downloading files...
176
226
  Hello, World
177
-
178
- The "-u" (or "--update") option tells fig to check the remote repository for packages if they aren't already installed locally (fig will never make any network connections unless this option is specified). Once the packages are downloaded, we can run the same command without the "-u" option:
227
+
228
+ The `-u` (or `--update`) option tells fig to check the remote repository for packages if they aren't already installed locally (fig will never make any network connections unless this option is specified). Once the packages are downloaded, we can run the same command without the `-u` option:
179
229
 
180
230
  $ fig -i hello/1.0.0 -- hello
181
231
  Hello, World
182
232
 
183
- Also, when including a package, you can specify a particular configuration by appending it to the package name using a colon:
233
+ When including a package, you can specify a particular configuration by appending it to the package name using a colon:
184
234
 
185
235
  $ fig -i hello/1.0.0:french -- hello
186
236
  Bonjour, World
187
237
 
188
238
  ### Retrieves ###
189
239
 
190
- By default, the resources associated with a package live in the fig home directory, which defaults to "~/.fighome". This doesn't always play nicely with IDE's however, so fig gives you a way to copy resources from the repository to the current directory. To do this you add "retrieve" statements to your "package.fig" file.
240
+ By default, the resources associated with a package live in the fig home
241
+ directory, which defaults to "$HOME/.fighome". This doesn't always play nicely with
242
+ IDE's however, so fig provides a "retrieve" statement to copy resources from the repository to
243
+ the current directory.
191
244
 
192
- For example, let's create a package that contains a library for the "foo" programming language. First we'll define a "package.fig" file:
245
+ For example, let's create a package that contains a library for the "foo" programming language. Define a "package.fig" file:
193
246
 
194
247
  config default
195
- append FOOPATH=lib/hello.foo
248
+ append FOOPATH=@/lib/hello.foo
196
249
  end
197
250
 
198
251
  Then:
199
252
 
200
253
  $ mkdir lib
201
254
  $ echo "print 'hello'" > lib/hello.foo
202
- $ fig --publish hello-lib/3.2.1
255
+ $ fig --publish hello-lib/3.2.1
203
256
 
204
- Now we'll move to a different directory (or delete the current "package.fig" file) and create a new "package.fig" file:
257
+ Create a new "package.fig" file (first moving to a different directory or deleting the "package.fig" we just used for publishing):
205
258
 
206
259
  retrieve FOOPATH->lib/[package]
207
260
  config default
208
261
  include hello-lib/3.2.1
209
262
  end
210
263
 
211
- When we do an update, all resources in the FOOPATH will be copied into the lib directory, into a subdirectory that matches the package name:
264
+ Upon a `fig --update`, each resource in FOOPATH will be copied into lib/[package], where [package] resolves to the resource's
265
+ package name (minus the version).
212
266
 
213
267
  $ fig -u
214
268
  ...downloading...
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.41
data/bin/fig CHANGED
@@ -1,190 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), %w< .. lib > ))
4
4
 
5
5
  require 'rubygems'
6
- require 'net/ftp'
7
6
 
8
- require 'fig/retriever'
9
- require 'fig/options'
10
- require 'fig/environment'
11
- require 'fig/repository'
12
- require 'fig/os'
13
- require 'fig/parser'
14
- require 'fig/windows'
7
+ require 'fig'
15
8
 
16
9
  include Fig
17
10
 
18
- def parse_descriptor(descriptor)
19
- # todo should use treetop for these:
20
- package_name = descriptor =~ /^([^:\/]+)/ ? $1 : nil
21
- config_name = descriptor =~ /:([^:\/]+)/ ? $1 : nil
22
- version_name = descriptor =~ /\/([^:\/]+)/ ? $1 : nil
23
- return package_name, config_name, version_name
24
- end
25
-
26
- shell_command = nil
27
- ARGV.each_with_index do |arg, i|
28
- if arg == "-"
29
- # $stderr.puts "Use of single dash (-) is deprecated. Use double dash (--) instead"
30
- # exit 1
31
- elsif arg == "--"
32
- shell_command = ARGV[(i+1)..-1]
33
- ARGV.slice!(i..-1)
34
- break
35
- end
36
- end
37
-
38
- options, argv = parse_options(ARGV)
39
-
40
- vars = {}
41
- ENV.each {|key,value| vars[key]=value }
42
-
43
- remote_url = nil
44
- if options[:update] || options[:publish] || options[:update_if_missing] || options[:list_remote]
45
- remote_url = ENV['FIG_REMOTE_URL']
46
- if remote_url.nil?
47
- $stderr.puts "Please define the FIG_REMOTE_URL environment variable"
48
- exit 1
49
- end
50
- end
51
-
52
- remote_user = nil
53
- if options[:publish]
54
- # remote_user = ENV['FIG_REMOTE_USER']
55
- # if remote_user.nil?
56
- # $stderr.puts "Please define the FIG_REMOTE_USER environment variable"
57
- # exit 1
58
- # end
59
- end
60
-
61
- os = OS.new(options[:login])
62
- repos = Repository.new(os, File.expand_path(File.join(options[:home], 'repos')), remote_url, remote_user, options[:update], options[:update_if_missing])
63
- retriever = Retriever.new(".")
64
- at_exit { retriever.save }
65
- env = Environment.new(os, repos, vars, retriever)
66
-
67
- options[:modifiers].each do |modifier|
68
- env.apply_config_statement(nil, modifier, nil)
69
- end
70
-
71
- #if File.exist?(".fig")
72
- # $stderr.puts "The '.fig' file is deprecated. Please rename to 'package.fig'"
73
- # exit 1
74
- #end
75
-
76
- DEFAULT_FIG_FILE = 'package.fig'
77
-
78
- input = nil
79
- if options[:input] == :none
80
- # ignore
81
- elsif options[:input] == '-'
82
- input = $stdin.read
83
- elsif options[:input].nil?
84
- input = os.read(DEFAULT_FIG_FILE) if os.exist?(DEFAULT_FIG_FILE)
85
- else
86
- if os.exist?(options[:input])
87
- input = os.read(options[:input])
88
- else
89
- $stderr.puts "File not found: #{options[:input]}"
90
- exit 1
91
- end
92
- end
93
-
94
- options[:cleans].each do |descriptor|
95
- package_name, version_name = descriptor.split('/')
96
- repos.clean(package_name, version_name)
97
- end
98
-
99
- if options[:list]
100
- repos.list_packages.sort.each do |item|
101
- puts item
102
- end
103
- exit 0
104
- end
105
-
106
- if options[:list_remote]
107
- repos.list_remote_packages.sort.each do |item|
108
- puts item
109
- end
110
- exit 0
111
- end
112
-
113
- if not options[:list_configs].empty?
114
- options[:list_configs].each do |descriptor|
115
- package_name, version_name = descriptor.split('/')
116
- repos.read_local_package(package_name, version_name).configs.each do |config|
117
- puts config.name
118
- end
119
- end
120
- exit 0
121
- end
122
-
123
- if input
124
- package = Parser.new.parse_package(nil, nil, ".", input)
125
- direct_retrieves=[]
126
- if options[:retrieve]
127
- package.retrieves.each do |var, path|
128
- if var =~ /^@([^\/]+)(.*)/
129
- direct_retrieves << [$1, $2, path]
130
- else
131
- env.add_retrieve(var, path)
132
- end
133
- end
134
- end
135
- unless options[:publish] || options[:list] || options[:publish_local]
136
- env.register_package(package)
137
- env.apply_config(package, options[:config], nil)
138
- direct_retrieves.each do |info|
139
- env.direct_retrieve(info[0], info[1], info[2])
140
- end
141
- end
142
- else
143
- package = Package.new(nil, nil, ".", [])
144
- end
145
-
146
- if options[:publish] || options[:publish_local]
147
- if !argv.empty?
148
- $stderr.puts "Unexpected arguments: #{argv.join(' ')}"
149
- exit 10
150
- end
151
- package_name, config_name, version_name = parse_descriptor(options[:publish] || options[:publish_local])
152
- if package_name.nil? || version_name.nil?
153
- $stderr.puts "Please specify a package name and a version name"
154
- exit 10
155
- end
156
- if not options[:modifiers].empty?
157
- publish_statements = options[:resources] + options[:archives] + [Configuration.new("default", options[:modifiers])]
158
- publish_statements << Publish.new("default","default")
159
- elsif not package.statements.empty?
160
- publish_statements = package.statements
161
- else
162
- $stderr.puts "Nothing to publish"
163
- exit 1
164
- end
165
- if options[:publish]
166
- puts "Checking status of #{package_name}/#{version_name}..."
167
- if repos.list_remote_packages.include?("#{package_name}/#{version_name}")
168
- puts "#{package_name}/#{version_name} has already been published"
169
- if not options[:force]
170
- puts "Use the --force option if you really want to overwrite, or us --publish-local for testing"
171
- exit 1
172
- else
173
- puts "Overwriting..."
174
- end
175
- end
176
- end
177
- puts "Publishing #{package_name}/#{version_name}"
178
- repos.publish_package(publish_statements, package_name, version_name, options[:publish_local])
179
- elsif options[:echo]
180
- puts env[options[:echo]]
181
- elsif shell_command
182
- argv.shift
183
- env.execute_shell(shell_command) { |cmd| os.shell_exec cmd }
184
- elsif argv[0]
185
- package_name, config_name, version_name = parse_descriptor(argv.shift)
186
- env.include_config(package, package_name, config_name, version_name, {}, nil)
187
- env.execute_config(package, package_name, config_name, nil, argv) { |cmd| os.shell_exec cmd }
188
- elsif input
189
- env.execute_config(package, nil, options[:config], nil, argv) { |cmd| os.shell_exec cmd }
190
- end
11
+ return_code = run_with_exception_handling(ARGV)
12
+ exit return_code