Skip to content

Instantly share code, notes, and snippets.

@gasche
Created November 20, 2015 15:27
Show Gist options
  • Save gasche/f7c03a07be04d02a281e to your computer and use it in GitHub Desktop.
Save gasche/f7c03a07be04d02a281e to your computer and use it in GitHub Desktop.
Need: we want the opam file commited in the opam-repository to be
formatted such that programmatically parsing and re-printing them is
a no-op. Today we don't have this, and this means that bulk script
changes to the opam-repository metadata creates much larger diff than
necessary.
In fact, we propose to install many different scripts named
opam-fmt-$OPAMVERSION
with each script depending on the corresponding version of opam-lib.
Then, we would have an
opam-fmt
script that would default to the script corresponding to the current
OPAM version.
Implementation detail: opam-fmt-$OPAMVERSION should refuse to process
opam files whose opam-version field is larger than $OPAMVERSION. It
should always produce output with an opam-version field equal to
$OPAMVERSION. This means in particular that using opam-fmt on an
opam file may silently update its opam-version field.
Versioning: opam-fmt-$OPAM_VERSION.$OPAMFMT_VERSION_NUMBER
Features:
opam fmt --version=$OPAMVER $ARGS
calls opam-fmt-$OPAMVER $ARGS
(by default, the current opam version)
opam fmt-$VER <file>
reads the opam file with opam-lib's parsing functions, and
re-print them on stdout with opam-lib's printing functions
opam fmt-$VER --stdin
reads the opam file on standard input
opam fmt-$VER [<file>|--stdin] --output <output-file>
opam fmt-$VER <file> --inplace
opam fmt-$VER --version
returns the OPAM version
opam fmt-$VER [<file>|--stdin] --check
fails with an error message if opam-fmt output would differ from
its input
to be used in opam-repository automatic QA
opam fmt-$VER
print usage message
Note in particular that
opam fmt --version=1.2 --version
is valid and prints 1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment