@@ -30,11 +30,7 @@ let watch_mode = ref false
30
30
let make_world = ref false
31
31
let do_install = ref false
32
32
let force_regenerate = ref false
33
- let bs_version_string = Bs_version. version
34
- let print_version_string () =
35
- print_string bs_version_string;
36
- print_newline () ;
37
- exit 0
33
+
38
34
type spec = Bsb_arg .spec
39
35
40
36
let call_spec f : spec = Unit (Unit_call f )
@@ -115,17 +111,7 @@ let install_target () =
115
111
if eid <> 0 then
116
112
Bsb_unix. command_fatal_error install_command eid
117
113
118
- let global_help () =
119
- print_string {| Available flags
120
- - v, - version display version number
121
- - h, - help display help
122
- Subcommands :
123
- build
124
- clean
125
- help
126
- Run rescript subcommand - h for more details, for example
127
- rescript build - h
128
- | }
114
+
129
115
130
116
let build_subcommand ~start argv argv_len =
131
117
let i = Ext_array. rfind_with_index argv Ext_string. equal separator in
@@ -189,7 +175,47 @@ let init_subcommand ~start argv =
189
175
Bsb_theme_init. init_sample_project
190
176
~cwd: Bsb_global_paths. cwd
191
177
~theme: ! current_theme location
192
- )
178
+ )
179
+
180
+ let list_files = ref false
181
+ let info_subcommand ~start argv =
182
+ Bsb_arg. parse_exn
183
+ ~usage: " query the project" ~start ~argv [|
184
+ " -list-files" , unit_set_spec list_files,
185
+ " list source files"
186
+ |] (fun
187
+ ~rev_args ->
188
+
189
+ (match rev_args with
190
+ | x :: _ ->
191
+ raise (Bsb_arg. Bad (" Don't know what to do with " ^ x))
192
+ | [] ->
193
+ () );
194
+ if ! list_files then begin
195
+ match
196
+ Bsb_ninja_regen. regenerate_ninja
197
+ ~package_kind: Toplevel
198
+ ~forced: true ~per_proj_dir: Bsb_global_paths. cwd with
199
+ | None -> assert false
200
+ | Some {file_groups = {files} } ->
201
+ Ext_list. iter files (fun {sources } ->
202
+ Map_string. iter sources (fun _ {info;syntax_kind;name_sans_extension} ->
203
+ let extensions =
204
+ match syntax_kind,info with
205
+ | _ , Intf -> assert false
206
+ | Reason , Impl -> [" .re" ]
207
+ | Reason , Impl_intf -> [" .re" ; " .rei" ]
208
+ | Ml , Impl -> [" .ml" ]
209
+ | Ml , Impl_intf -> [" .ml" ; " .mli" ]
210
+ | Res , Impl -> [" .res" ]
211
+ | Res , Impl_intf -> [" .res" ; " .resi" ] in
212
+ Ext_list. iter extensions (fun x ->
213
+ print_endline (name_sans_extension ^ x )
214
+ )
215
+ )
216
+ )
217
+ end
218
+ ) ;;
193
219
(* see discussion #929, if we catch the exception, we don't have stacktrace... *)
194
220
let () =
195
221
let argv = Sys. argv in
@@ -203,21 +229,15 @@ let () =
203
229
~per_proj_dir: Bsb_global_paths. cwd |> ignore;
204
230
ninja_command_exit [||]
205
231
end else
206
-
207
-
208
-
209
232
match argv.(1 ) with
210
- | " -version" | " -v"
211
- -> print_version_string ()
212
- | " -help" | " -h"
213
- -> global_help ()
214
233
| "build" ->
215
234
build_subcommand ~start: 2 argv argv_len
216
235
| "clean" ->
217
236
clean_subcommand ~start: 2 argv
218
237
| "init" ->
219
238
init_subcommand ~start: 2 argv
220
- | "help" -> global_help ()
239
+ | "info" -> (* internal *)
240
+ info_subcommand ~start: 2 argv
221
241
| first_arg ->
222
242
prerr_endline @@ " Unknown subcommand or flags: " ^ first_arg;
223
243
exit 1
0 commit comments