cwl-d 0.1.2
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
Autogenerated classes for reading and writing CWL objects using the D language.
It integrates with schema-salad-d and provides the following features:
- Support almost 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_d_auto.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_d_auto.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/1.2.1_proposed/CommonWorkflowLanguage.yml --codegen-package cwl_d_auto.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 viacwl.v1_2.parserInfo
.
How to use
See source/app.d for a concrete example.
import cwl_d_auto.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_d_auto
.
$ dub test
Future plan
- Support extension fields
- Support CWL documents that are based on YAML v1.2
- e.g., Documents in which there is
:
in the unquoted strings
- Registered by Tomoya Tanjo
- 0.1.2 released 2 years ago
- common-workflow-lab/cwl-d-auto
- github.com/common-workflow-lab/cwl-d-auto
- Apache-2.0
- Copyright © 2022, Tomoya Tanjo
- Authors:
- Dependencies:
- schema-salad-d
- Versions:
-
1.0.3 2024-Oct-02 1.0.2 2024-Sep-26 1.0.1 2024-Sep-26 1.0.0 2024-Sep-26 0.3.1 2024-Mar-31 - Download Stats:
-
-
0 downloads today
-
3 downloads this week
-
7 downloads this month
-
317 downloads total
-
- Score:
- 1.2
- Short URL:
- cwl-d.dub.pm