Permalink
Browse files

added a simple cli interface: ocamlas

  • Loading branch information...
1 parent 606a5f4 commit 17efecd067fca4878ae37d8a9d1d954dd328392c @camlspotter camlspotter committed Feb 15, 2013
Showing with 58 additions and 9 deletions.
  1. +22 −6 OMakefile
  2. +14 −0 base.ml
  3. +11 −0 base.mli
  4. +1 −1 chconfig.ml
  5. +2 −0 controller.mli
  6. +2 −1 modules-init.sh
  7. +6 −1 searchid.ml
View
@@ -1,3 +1,5 @@
+.PHONY: clean all
+
USE_OCAMLFIND = true
OCAMLPACKS[] =
@@ -18,7 +20,7 @@ OCAMLINCLUDES += ../typing
NATIVE_ENABLED = true
BYTE_ENABLED = true
-FILES[] =
+CGI_FILES[] =
chconfig
controller
hList
@@ -28,23 +30,37 @@ FILES[] =
base
main
-PROGRAM = index.cgi
+CGI_PROGRAM = index.cgi
+
+all:: $(OCamlProgram $(CGI_PROGRAM), $(CGI_FILES))
+
+CLI_FILES[] =
+ chconfig
+ controller
+ hList
+ list2
+ searchid
+ search
+ base
+ cli
+
+CLI_PROGRAM = ocamlas
+
+all:: $(OCamlProgram $(CLI_PROGRAM), $(CLI_FILES))
# OCAML_LIBS +=
# OCAML_CLIBS +=
# OCAML_OTHER_LIBS += toplevellib
# OCAML_LIB_FLAGS +=
#
-.PHONY: clean all
-
-all: $(OCamlProgram $(PROGRAM), $(FILES)) modules.txt
+all:: modules.txt
modules.txt : modules-init.sh
./modules-init.sh
clean:
- rm -f *.cm[oix] *.o *.omc $(PROGRAM) *.run *~ *.annot
+ rm -f *.cm* *.o *.omc $(CGI_PROGRAM) $(CLI_PROGRAM) *.run *.opt *~ *.annot *Test-runner
.DEFAULT: all
View
@@ -128,3 +128,17 @@ let open_in_with path f =
let undefined = Obj.magic 42
let undef = undefined
+
+let rec format_list (sep : (unit, Format.formatter, unit) format) f ppf = function
+ | [] -> ()
+ | [x] -> f ppf x
+ | x::xs ->
+ Format.fprintf ppf "@[%a@]%t%a"
+ f x
+ (fun ppf -> Format.fprintf ppf sep)
+ (format_list sep f) xs
+
+let format_ocaml_list f ppf xs =
+ Format.fprintf ppf "[ @[%a@] ]"
+ (format_list ";@ " f) xs
+
View
@@ -44,3 +44,14 @@ val open_out_with : string -> (out_channel -> 'a) -> 'a
val open_in_with : string -> (in_channel -> 'a) -> 'a
val undefined : 'a
val undef : 'a
+
+val format_list :
+ (unit, Format.formatter, unit) format
+ -> (Format.formatter -> 'a -> unit)
+ -> Format.formatter -> 'a list -> unit
+(** Format for lists *)
+
+val format_ocaml_list :
+ (Format.formatter -> 'a -> unit)
+ -> Format.formatter -> 'a list -> unit
+(** Format for lists in OCaml style [ a; b; ... ] *)
View
@@ -32,7 +32,7 @@ let r_path =
regexp "^PATH *:: *\\(.*\\)$"
let parse_line s =
- if s = "" then
+ if s = "" || s.[0] = '#' then
()
else if string_match r_path s 0 then
path := Some (matched_group 1 s)
View
@@ -4,5 +4,7 @@ type t =
| Table of (string * t) list list
val format : Chconfig.t list -> Search.t -> (string * t) list
+(** formatter for [Search.t] *)
+
val pagenation : offset:int -> window:int -> 'a list -> (string * t) list * 'a list
val available : Chconfig.t list -> t
View
@@ -2,7 +2,8 @@
cat <<EOF > modules.txt
- stdlib
-PATH:: `ocamlfind query unix`
+# Thread realted modules are found in the next PATH spec. The others are found in the default one.
+PATH:: `ocamlfind query threads.posix`
Pervasives
Arg
Array
View
@@ -377,7 +377,12 @@ let search_pattern_symbol text =
| _ -> []
end
| _ -> []
- with Env.Error _ -> []
+ with Env.Error _ ->
+ Format.eprintf "Error: lookup_module %s failed@." modname;
+ []
+ | Not_found ->
+ Format.eprintf "Error: search_pattern_symbol raised Not_found for %s@." modname;
+ []
end
in
List2.flat_map l ~f:

0 comments on commit 17efecd

Please sign in to comment.