mirage / ocaml-crunch

Convert a filesystem into a static OCaml module
Other
74 stars 21 forks source link

Specify the list of files to embed + use identifiers to access embed files #44

Open ghost opened 6 years ago

ghost commented 6 years ago

I'm currently looking at releasing a sexp command line tool that we developed a long time ago at Jane Street. The build of this tool uses an embed-file tool that we developed as well. I looked at embed-file and it is very similar to ocaml-crunch, so I'd like to replace our embed-file by ocaml-crunch, to avoid releasing a project that is very similar to it.

There are a few differences between the two tools. For now I can workaround these, but eventually I'd like to not have these workarounds, so I'm opening this PR to see if you'd be happy supporting the features described below. I can provide patches if yes.

The two features are:

  1. we can specify a list of files rather than a directory. In the sexp case, we only embed a selected list of files from a directory
  2. we access embed files using OCaml identifiers rather than filenames. i.e. for the following list of files: change_by_example.md, change_semantics.md, query_by_example.md and query_semantics.md, we generate:
    val query_by_example_dot_md : string
    val query_semantics_dot_md : string
    val change_by_example_dot_md : string
    val change_semantics_dot_md : string

    The advantage being that you get a compilation error if you type the wrong file name.

mro commented 2 years ago

Hi @jeremiedimino, @samoht, what happened to it? I'd like to embed files in a nested .well-known directory that's ignored. So piping in a file list would be ideal.

mro commented 2 years ago

@hannesm @MisterDA any chance an explicit file list on stdin thus enabling dot directories?

hannesm commented 2 years ago

@mro sure the semantics can be adjusted. Please open a PR (including tests) about what you'd like to achieve / what is currently not working. I barely use crunch these days, but am happy to have it being useful for more people.

MisterDA commented 2 years ago

I'd be happy to hack something. I think the semantics of GNU tar --from-file are reasonable (although we don't have to interpret CLI switches inside the list of files). They also have the advantage of being de-facto standard.