Getting started
Add click2cwl dependency:
name: my_env
channels:
  - terradue
  - conda-forge
dependencies:
  - python
  pip:
  - click2cwl
Usage
First import the click2cwl dump function with:
from click2cwl import dump
Then, in the Python application entry point function, update and enrich the Click function decorator with the information for generating the CWL document.
The information defined at the Click function decorator is explained below:
@click.command
The @click.command decorator must:
- set the 
allow_extra_argsflag toTrue. This allows using the command line interface to pass the runtime information to generate the CWL. - set the 
short_helpto define the CWL Workflow class label - set the 
helpto define the CWL Workflow class doc 
@click.command(
    short_help="This is Workflow class label",
    help="This is Workflow class doc",
    context_settings=dict(
        ignore_unknown_options=True,
        allow_extra_args=True,
    ),
)
@click.option
The @click.option decorator must:
- define the option type that can be 
click.Pathfor aDirectory, aclick.Filefor aFileor the default, aStringto map asstring - set the 
helpto define the CWL Workflow class doc and label - set the 
requiredflag toFalseif the parameter is optional 
@click.option(
    "--input_path",
    "-i",
    "input_path",
    type=click.Path(),
    help="this input path",
    multiple=False,
    required=True,
)
Finally, invoke the dump function in your Click decorated function with:
@click.command ...
@click.option ...
@click.pass_context
def main(ctx, **kwargs):
    dump(ctx)
    print("business as usual")
    print(kwargs)
if __name__ == '__main__':
    main()
Note: See the examples folder to discover typical use cases.
Install your application with:
python setup.py install
When the app help is invoked, it will only show the arguments defined by the click.decorators:
myapp --help
but it now supports additional args to drive the generation of the CWL document and associated parameters:
The additional args are:
--dumpcwl|params|clt. Example--dump cwl --dump paramswill dump the CWL document and the CWL parameters template in YAML.cltwill dump the CWlCommandLineToolclass only (no Workflow)--requirementwithrequirement=valuewhere requirement here is one of"coresMin","coresMax","ramMin","ramMax". Example:--requirement ramMax=1 --requirement ramMin=2--docker <docker image>if set, theDockerRequirementhint is set to pull the<docker image>--envsets environment variables in the CWL withenv_var=env_var_value. Example--env A=1 --env B=2where A and B are the environment variables to set in the CWLEnvVarRequirementrequirement