# How to output non-file types from a CommandLineTool?

**URL:** <https://cwl.discourse.group/t/how-to-output-non-file-types-from-a-commandlinetool/565>\
**Category:** CWL Questions\
**Created:** [March 1, 2022, 2:23pm UTC](https://cwl.discourse.group/t/how-to-output-non-file-types-from-a-commandlinetool/565 "2022-03-01T14:23:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@steve](https://cwl.discourse.group/u/steve)\
**Post date:** [March 1, 2022, 2:23pm UTC](https://cwl.discourse.group/t/how-to-output-non-file-types-from-a-commandlinetool/565/1 "2022-03-01T14:23:22Z")

</div>

I saw this page here:

[https://www.commonwl.org/user\_guide/misc/](https://www.commonwl.org/user_guide/misc/)

Which describes how to load data from a file in order to output it ;

* * *

### Non “`File`” types using `evalFrom`

```auto
cwlVersion: v1.0 # or v1.1
class: CommandLineTool
requirements:
  InlineJavascriptRequirement: {}

baseCommand: [echo, "42"]

inputs: []

stdout: my_number.txt

outputs:
  my_number:
    type: int
    outputBinding:
       glob: my_number.txt
       loadContents: True
       outputEval: $(parselnt(self[0].contents))

  my_number_as_string:
    type: string
    outputBinding:
       glob: my_number.txt
       loadContents: True
       outputEval: $(self[0].contents)

```

* * *

However, this is not what I want. In these examples, you would have to write out all your data into files and then load them back into output objects from files.

I want to be able to pass in any arbitrary input into a CommandLineTool, then pass that (or other) data back out, regardless of the involvement of any file. For example:

```auto
cwlVersion: v1.0 # or v1.1
class: CommandLineTool
requirements:
  InlineJavascriptRequirement: {}

baseCommand: [touch, newfile.txt]

inputs:
  some_value: int
  some_file: File

outputs:
  some_value: 
    value: $(inputs.some_value)
    type: int
  some_other_value: 
    value: ${ return `some_JS_expression_result` ; }
    type: int
  new_file:
    type: File
    outputBinding: 
      glob: newfile.txt

```

This is just a basic example with primitive data types, but ultimately what I would really like is the ability to pass in a `record` type as an input, with one or more fields including `File` objects, then inside my CommandLineTool do some processing to make a new file, and then output that same `record` but with an updated `File` in its fields.

I have tried writing this myself but I get syntax or “incorrect field” errors every time.

The CWL spec here describes several different `types`’s of CommandOutput and CommandOutputRecord object;

[https://www.commonwl.org/v1.0/CommandLineTool.html](https://www.commonwl.org/v1.0/CommandLineTool.html)

But I have not been able to find any real-world examples that show how to output anything from `CommandLineTool` that is not from a file.

---

<div class="post-metadata">

**Author:** ![mrc](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/mrc/32/3_2.png) [@mrc](https://cwl.discourse.group/u/mrc)\
**Post date:** [March 1, 2022, 3:31pm UTC](https://cwl.discourse.group/t/how-to-output-non-file-types-from-a-commandlinetool/565/2 "2022-03-01T15:31:15Z")

</div>

Hello @steve

What you describe should be possible.

You can have an `outputBinding` for records both at the overall record level, or at the level of each field of the record.

For an example of the overall record level `outputBinding` see [Test for outputEval on a record type itself, not its fields · common-workflow-language/cwl-v1.2@5551e59 · GitHub](https://github.com/common-workflow-language/cwl-v1.2/commit/5551e596fe90456a5d44483793a65d75d48f6330#diff-1887162d14de9005da7614bcd290b53c3865befc88bf15d3861a097fcc90df29R32)

Does that help?

---

<div class="post-metadata">

**Author:** ![steve](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@steve](https://cwl.discourse.group/u/steve)\
**Post date:** [March 1, 2022, 9:04pm UTC](https://cwl.discourse.group/t/how-to-output-non-file-types-from-a-commandlinetool/565/3 "2022-03-01T21:04:57Z")

</div>

Thanks, that helped a lot. I was able to combine that with [“custom data types”](https://www.commonwl.org/user_guide/19-custom-types/index.html) to get some demo’s of taking a custom record with a `File` field as input, then outputting the record with a new file from a command line tool

[https://github.com/stevekm/cwl-demos/blob/746d9b24c5277de99ee117d3f859f6218e0de120/custom-types/sampletypes.cwl](https://github.com/stevekm/cwl-demos/blob/master/custom-types/sampletypes.cwl)

[https://github.com/stevekm/cwl-demos/blob/746d9b24c5277de99ee117d3f859f6218e0de120/custom-types-array/sampletypes.cwl](https://github.com/stevekm/cwl-demos/blob/master/custom-types-array/sampletypes.cwl)
