[Cbor] CDDL conversion utilities

Carsten Bormann <cabo@tzi.org> Sat, 20 July 2019 21:09 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6E7BC1200F8 for <cbor@ietfa.amsl.com>; Sat, 20 Jul 2019 14:09:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.197
X-Spam-Level:
X-Spam-Status: No, score=-4.197 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TjXFYYSTq8_T for <cbor@ietfa.amsl.com>; Sat, 20 Jul 2019 14:09:08 -0700 (PDT)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1D769120048 for <cbor@ietf.org>; Sat, 20 Jul 2019 14:09:08 -0700 (PDT)
Received: from dhcp-80d9.meeting.ietf.org (dhcp-80d9.meeting.ietf.org [31.133.128.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 45rgTs6Nh2zyT6; Sat, 20 Jul 2019 23:09:05 +0200 (CEST)
From: Carsten Bormann <cabo@tzi.org>
Content-Type: text/plain; charset=utf-8
X-Mao-Original-Outgoing-Id: 585349741.460566-810de80994e814f3584baf98dc9a6fc3
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\))
Date: Sat, 20 Jul 2019 17:09:03 -0400
Message-Id: <9D882C89-839C-456A-8FA7-5D6F40B2AF5C@tzi.org>
To: cbor@ietf.org
X-Mailer: Apple Mail (2.3445.9.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/wq2UVq9hWIZEWBkxlV2FxVdjbPo>
Subject: [Cbor] CDDL conversion utilities
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 20 Jul 2019 21:09:10 -0000

First fruit of the hackathon today: cddlc.

$ echo “foo = true / 3" | cddlc -
["cddl", ["=", ["name", "foo"], ["tcho", ["name", "true"], ["number", "3"]]]]

README (https://github.com/cabo/cddlc) below.

Grüße, Carsten


# CDDL conversion utilities

This little set of tools provides a number of command line utilities
for converting to and from [cddl][RFC8610].

## Installation

`gem install cddlc`

## Formats

cddlc knows the following formats:

* .cddl: CDDL as defined in [RFC8610][]
* .cddlj: JSON form of CDDL (the YIN to the YANG)
* .cddly: The same JSON form, but serialized in YAML.

[RFC8610]: http://tools.ietf.org/html/rfc8610

These targets are identified by `-t cddl`, `-t json` (with `-t neat` invoking
a different prettyprinter), `-t yaml`.  These can be abbreviated (but
don't do that in scripts).

The current version only can transform from input CDDL to one of the
JSON/YAML formats of CDDL.

## Command line utilities

* `cddlc foo.cddl > foo.cddlj`
* `cddlc -tyaml foo.cddl > foo.cddly`
* `cddlc -ty foo.cddl > foo.cddly`

Output is to stdout, input from one or more files given as command line
arguments (use `-` for standard input).