cwl-d 1.0.4

Autogenerated classes for reading and writing CWL objects using the D language.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

cwl-d-auto

build license code.dlang.org

Autogenerated classes for reading and writing CWL objects using the D language.

It integrates with schema-salad-d and provides the following features:

  • Support all the CWL v1.0, v1.1 and v1.2 documents
  • Load YAML files and nodes to generate corresponding D objects
  • Store D object for CWL to YAML nodes

How is the parser generated?

Each parser is generated with schema-salad-tool as shown below.

  • CWL v1.0
  $ schema-salad-tool --codegen dlang https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/CommonWorkflowLanguage.yml --codegen-package cwl.v1_0 --codegen-parser-info "CWL v1.0 parser generated with schema-salad-tool" --codegen-examples resources/cwl-v1.0 > v1_0.d
  • CWL v1.1
  $ schema-salad-tool --codegen dlang https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/CommonWorkflowLanguage.yml --codegen-package cwl.v1_1 --codegen-parser-info "CWL v1.1 parser generated with schema-salad-tool" --codegen-examples resources/cwl-v1.1 > v1_1.d
  • CWL v1.2
  $ schema-salad-tool --codegen dlang https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/CommonWorkflowLanguage.yml --codegen-package cwl.v1_2 --codegen-parser-info "CWL v1.2 parser generated with schema-salad-tool" --codegen-examples resources/cwl-v1.2 > v1_2.d
  • You can specify the package name via --codegen-package.
  • You can add informative message into the generated package via --codegen-parser-info. It can be accessed via cwl.v1_2.parserInfo.

How to use

See source/app.d for a concrete example.

import cwl.v1_0; // auto generated CWL parser
import salad.resolver : absoluteURI;

import dyaml : Node;
import std : match, tryMatch, writefln;

///// Loading file

auto uri = file.absoluteURI;

// dispatch with std.sumtype.match for loaded object
auto doc = importFromURI(uri).match!(
	// typical case
	(DocumentRootType r) => r,
	// When loaded CWL has `$graph`, the result is DocumentRootType[]
	(DocumentRootType[] rs) => rs[0],
);

// use std.sumtype.tryMatch if you can assume the type of target object 
// The following `tryMatch` assumes `doc` is CLT or Workflow. Otherwise it throws an exception
auto classStr = doc.tryMatch!(
	(CommandLineTool clt) => "CommandLineTool",
	(Workflow wf) => "Workflow",
);
		
writefln!"%s is %s class."(uri, classStr);

///// Convert CWL object to YAML node
auto yamlNode = doc.match!(d => Node(d));

How to run the example

The example just prints the document class of a given CWL document.

$ dub run -c demo -- resources/cwl-v1.0/valid_rename.cwl
...
Running cwl-d-auto resources/cwl-v1.0/valid_rename.cwl
file:///workspaces/cwl-d-auto/resources/cwl-v1.0/valid_rename.cwl is CommandLineTool class.

How to test

It checks that CWL documents in resources can be loaded with parsers in source/cwl.

$ dub test
Authors:
  • Tomoya Tanjo
Dependencies:
schema-salad-d
Versions:
1.0.4 2024-Oct-24
1.0.3 2024-Oct-02
1.0.2 2024-Sep-26
1.0.1 2024-Sep-26
1.0.0 2024-Sep-26
Show all 16 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 317 downloads total

Score:
1.1
Short URL:
cwl-d.dub.pm