package opam-ed

  1. Overview
  2. Docs
Command-line edition tool for handling the opam file syntax

Install

Dune Dependency

Authors

Maintainers

Sources

0.4.tar.gz
md5=f2a065cdaca8436bd4879c75d6209ed6
sha512=baad099460dee04dad48ddc55af1ce3671e0e694d1b0ec5d3ea58b3972f9444379fcb6d0413277ec24dbda9cd01b7b31ea112e470e32721ea223b69c90550009

Description

opam-ed can read and write files in the general opam syntax. It provides a small CLI with some useful commands for mechanically extracting or modifying the file contents.

The specification for the syntax itself is available at: http://opam.ocaml.org/doc/Manual.html#Common-file-format

Published: 16 Aug 2023

README

opam-ed: a small command-line edition tool for the opam syntax

opam-ed can read and write files in the general opam syntax. It provides a small CLI with some useful commands for extracting or modifying the file contents.

The program reads from stdin, writes to stdout, and processes each argument as one of the commands listed below. See opam-ed --help for more options.

Commands

(as extracted from the generated manpage)

  • get FIELD Print out the value of the named FIELD.

  • field-list List the field names present in the input.

  • field-items FIELD Print out the items of FIELD, understood as a list, separated by newlines.

  • get-section SECTION Extract and print the contents of the given SECTION.

  • add FIELD value Add the given FIELD, with the given contents, to the file, if it didn't exist already

  • remove FIELD Remove the given FIELD from the file, if present.

  • replace FIELD value Replace the contents of the given FIELD, if found, by the given value.

  • add-replace FIELD value Replace the contents of the given FIELD by the given value, adding the field if not present already. This is equivalent to the sequence 'remove FIELD' 'add FIELD value'

  • append FIELD value Append the given value to the given FIELD, treated as a list. The field is created as a singleton if it didn't exist

  • prepend FIELD value Prepend the given value to the given FIELD, treated as a list. The field is created as a singleton if it didn't exist

  • map FIELD command Run the given shell command with each member of FIELD, treated as a list, as input, and replace it by the output of the command.

  • filter FIELD cmd Run the given shell command with each member of FIELD, treated as a list, as input, and remove any member for which the command doesn't return 0.

  • replace-item FIELD value replacement Replace the first item of the contents of FIELD, treated as a list, that is equal to value, with replacement. Nothing happens if value is not a member of the FIELD.

  • add-replace-item FIELD value replacement Replace the first item of the contents of FIELD, treated as a list, that is equal to value, with replacement. replacement is appended to FIELD if value was not found.

  • remove-item FIELD value Remove the first item of the contents of FIELD, treated as a list, that is equal to value, if any.

License

Copyright 2017-2023 OCamlPro. opam-ed is distributed under the terms of the GNU General Public License version 2.1, with the special exception on linking describted in the file LICENSE.

Dependencies (4)

  1. opam-file-format >= "2.0.0"
  2. cmdliner >= "1.0.0"
  3. dune >= "2.0"
  4. ocaml >= "4.03.0"

Dev Dependencies

None

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.