Sha256: cbce1e85b6be04f32945b7868f42abdb4cd0319e371e62867df7da3e6a351d37

Contents?: true

Size: 1.83 KB

Versions: 70

Compression:

Stored size: 1.83 KB

Contents

open Core
open Languages

let is_directory =
  Command.Spec.Arg_type.create
    (fun n ->
       match Sys.is_directory n with
       | `Yes -> n
       | `No | `Unknown ->
         eprintf "'%s' is not a regular folder.\n%!" n;
         exit 1
    )

let home_dir = Option.value_exn (Sys.getenv "HOME")

let default_generated name = Option.value ~default:(home_dir ^ "/.exercism-" ^ name ^ "-generated")

let command =
  let open Command.Let_syntax in
  Command.basic
    ~summary:"Generates test code from canonical data."
    ~readme: (fun () -> "Generates test code from canonical data.")
    [%map_open
      let language = flag "l" (optional string) ~doc:"language to generate tests for"
      and templates_folder = flag "t" (optional_with_default "./templates" is_directory) ~doc:"string Directory containing templates."
      and canonical_data_folder = flag "c" (optional_with_default "../../../problem-specifications/exercises" is_directory) ~doc:"string Directory containing canonical data."
      and output_folder = flag "-o" (optional string) ~doc:"string Directory to output generated tests."
      and generated_folder = flag "-g" (optional string) ~doc:"string Directory to backup generated tests."
      and filter = flag "-f" (optional string) ~doc:"string Filter out files not matching this string."
      in
      fun () ->
        let language = Option.value language ~default:"ocaml" in
        let lc = default_language_config language in
        let generated_folder = default_generated language generated_folder in
        let templates_folder = templates_folder ^ "/" ^ language in
        let output_folder = Option.value output_folder ~default:(lc.default_base_folder ^ "/exercises") in
        Controller.run lc templates_folder canonical_data_folder output_folder generated_folder filter
    ]

let () =
  Command.run ~version:"0.1" command

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.179 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.178 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.177 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.176 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.175 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.174 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.173 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.172 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.171 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.170 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.169 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.167 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.166 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.165 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.164 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.163 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.162 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.161 tracks/ocaml/tools/test-generator/src/test_gen.ml
trackler-2.2.1.160 tracks/ocaml/tools/test-generator/src/test_gen.ml