@@ -126,10 +126,21 @@ fn pretty_print_input(session.session sess,
126
126
pretty. pprust . print_file ( crate . node. module , input, std. io . stdout ( ) ) ;
127
127
}
128
128
129
+ fn version ( str argv0 ) {
130
+ auto git_rev = "" ; // when snapshotted to extenv: #env("GIT_REV");
131
+ if ( _str. byte_len ( git_rev) != 0 u) {
132
+ git_rev = #fmt ( " (git: %s)" , git_rev) ;
133
+ }
134
+ io. stdout ( ) . write_str ( #fmt ( "%s prerelease%s\n " , argv0, git_rev) ) ;
135
+ }
136
+
129
137
fn usage ( str argv0 ) {
130
138
io. stdout ( ) . write_str ( #fmt ( "usage: %s [options] <input>\n " , argv0) + "
131
139
options:
132
140
141
+ -h --help display this message
142
+ -v --version print version info and exit
143
+
133
144
-o <filename> write output to <filename>
134
145
--glue generate glue.bc file
135
146
--shared compile a shared-library crate
@@ -146,8 +157,7 @@ options:
146
157
--save-temps write intermediate files in addition to normal output
147
158
--time-passes time the individual phases of the compiler
148
159
--sysroot <path> override the system root (default: rustc's directory)
149
- --no-typestate don't run the typestate pass (unsafe!)
150
- -h display this message\n \n " ) ;
160
+ --no-typestate don't run the typestate pass (unsafe!)\n \n " ) ;
151
161
}
152
162
153
163
fn get_os ( ) -> session . os {
@@ -173,7 +183,9 @@ fn main(vec[str] args) {
173
183
uint_type = common. ty_u32 ,
174
184
float_type = common. ty_f64 ) ;
175
185
176
- auto opts = vec ( optflag ( "h" ) , optflag ( "glue" ) ,
186
+ auto opts = vec ( optflag ( "h" ) , optflag ( "help" ) ,
187
+ optflag ( "v" ) , optflag ( "version" ) ,
188
+ optflag ( "glue" ) ,
177
189
optflag ( "pretty" ) , optflag ( "ls" ) , optflag ( "parse-only" ) ,
178
190
optflag ( "O" ) , optflag ( "shared" ) , optmulti ( "L" ) ,
179
191
optflag ( "S" ) , optflag ( "c" ) , optopt ( "o" ) , optopt ( "g" ) ,
@@ -189,11 +201,18 @@ fn main(vec[str] args) {
189
201
}
190
202
case ( GetOpts . success ( ?m) ) { match = m; }
191
203
}
192
- if ( opt_present ( match , "h" ) ) {
204
+ if ( opt_present( match , "h" ) ||
205
+ opt_present( match , "help" ) ) {
193
206
usage( binary) ;
194
207
ret;
195
208
}
196
209
210
+ if ( opt_present( match, "v" ) ||
211
+ opt_present( match, "version" ) ) {
212
+ version( binary) ;
213
+ ret;
214
+ }
215
+
197
216
auto pretty = opt_present( match, "pretty" ) ;
198
217
auto ls = opt_present( match, "ls" ) ;
199
218
auto glue = opt_present( match, "glue" ) ;
0 commit comments