-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
*.annot | ||
*.cmo | ||
*.cma | ||
*.cmi | ||
*.a | ||
*.o | ||
*.cmx | ||
*.cmxs | ||
*.cmxa | ||
|
||
# ocamlbuild working directory | ||
_build/ | ||
www/ | ||
_www/ | ||
|
||
# ocamlbuild targets | ||
*.byte | ||
*.native | ||
*.exe | ||
|
||
# oasis generated files | ||
setup.data | ||
setup.log | ||
|
||
# Merlin configuring file for Vim and Emacs | ||
.merlin | ||
|
||
# Dune generated files | ||
*.install | ||
|
||
# Local OPAM switch | ||
_opam/ | ||
|
||
# Node js | ||
node_modules/ | ||
|
||
# Krita and emacs temp files | ||
*~ | ||
|
||
# Do not upload the cache | ||
cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
let docs = Cmdliner.Manpage.s_common_options | ||
|
||
let target ?(default = Yocaml.Path.rel [ "_www" ]) () = | ||
let doc = "Target directory" in | ||
let arg = Cmdliner.Arg.info ~doc ~docs [ "target"; "output" ] in | ||
Cmdliner.Arg.(value @@ opt Conv.path default arg) | ||
;; | ||
|
||
let source ?(default = Yocaml.Path.rel []) () = | ||
let doc = "Source directory" in | ||
let arg = Cmdliner.Arg.info ~doc ~docs [ "source"; "input" ] in | ||
Cmdliner.Arg.(value @@ opt Conv.path default arg) | ||
;; | ||
|
||
let port ?(default = 8888) () = | ||
let doc = "The development server's listening port" in | ||
let arg = Cmdliner.Arg.info ~doc ~docs [ "port"; "P" ] in | ||
Cmdliner.Arg.(value @@ opt Conv.port default arg) | ||
;; | ||
|
||
let log_level ?(default = `App) () = | ||
let doc = "The log-level of the application running" in | ||
let arg = Cmdliner.Arg.info ~doc ~docs [ "log-level"; "level"; "log" ] in | ||
Cmdliner.Arg.(value @@ opt Conv.log_level default arg) | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
val target : ?default:Yocaml.Path.t -> unit -> Yocaml.Path.t Cmdliner.Term.t | ||
val source : ?default:Yocaml.Path.t -> unit -> Yocaml.Path.t Cmdliner.Term.t | ||
val port : ?default:int -> unit -> int Cmdliner.Term.t | ||
|
||
val log_level | ||
: ?default:([ `App | `Info | `Error | `Warning | `Debug ] as 'loglevel) | ||
-> unit | ||
-> 'loglevel Cmdliner.Term.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
module C = Conv | ||
module A = Arg | ||
|
||
let program () = Yocaml.Eff.log ~level:`Debug "Hello World" | ||
let () = Yocaml_eio.run ~level:`Debug program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
let path = | ||
let docv = "PATH" | ||
and validate str = str |> Yocaml.Path.from_string |> Result.ok | ||
and pp = Yocaml.Path.pp in | ||
Cmdliner.Arg.conv ~docv (validate, pp) | ||
;; | ||
|
||
let port = | ||
let docv = "PORT" | ||
and validate str = | ||
match int_of_string_opt str with | ||
| None -> Result.error (str ^ " is not a valid port") | ||
| Some x when x < 0 -> Result.error (str ^ " must be positive") | ||
| Some x when x > 9999 -> Result.error (str ^ " must be lower than 9999") | ||
| Some x -> Result.ok x | ||
and pp ppf = Format.fprintf ppf "%04d" in | ||
Cmdliner.Arg.conv' ~docv (validate, pp) | ||
;; | ||
|
||
let log_level = | ||
let docv = "LOG_LEVEL" | ||
and validate str = | ||
match str |> String.trim |> String.lowercase_ascii with | ||
| "a" | "app" -> Result.ok `App | ||
| "i" | "info" -> Result.ok `Info | ||
| "e" | "err" | "error" -> Result.ok `Error | ||
| "w" | "warn" | "warning" -> Result.ok `Warning | ||
| "d" | "debug" -> Result.ok `Debug | ||
| _ -> Result.error "Invalid log-level" | ||
and pp pf s = | ||
Format.fprintf | ||
pf | ||
"%s" | ||
(match s with | ||
| `App -> "app" | ||
| `Info -> "info" | ||
| `Error -> "error" | ||
| `Warning -> "warning" | ||
| `Debug -> "debug") | ||
in | ||
Cmdliner.Arg.conv' ~docv (validate, pp) | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
val path : Yocaml.Path.t Cmdliner.Arg.conv | ||
val port : int Cmdliner.Arg.conv | ||
val log_level : [ `App | `Info | `Error | `Warning | `Debug ] Cmdliner.Arg.conv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(executable | ||
(name capsule) | ||
(public_name capsule) | ||
(libraries yocaml yocaml_eio)) | ||
(libraries yocaml yocaml_eio static cmdliner)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters