Skip to content

Commit

Permalink
More CLI help texts, link to cds.compile (#1550)
Browse files Browse the repository at this point in the history
- Add more CLI texts
- Link from and to the CLI page

---------

Co-authored-by: Steffen Waldmann <[email protected]>
  • Loading branch information
chgeo and swaldmann authored Jan 11, 2025
1 parent 617b731 commit f0f2189
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 5 deletions.
7 changes: 5 additions & 2 deletions .github/cli/grab-cli-texts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ pushd `dirname ${proj}` && cds init `basename ${proj}` && pushd `basename ${proj

echo
echo "Grabbing CLI texts..."
${dir}/grab-cli-texts.js @sap/cds-dk "cds add --help" ${proj} > ${dir}/../../tools/assets/help/cds-add.out.md
${dir}/grab-cli-texts.js @cap-js/cds-typer "cds-typer --help" ${proj} > ${dir}/../../tools/assets/help/cds-typer.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds --help" ${proj} > ${dir}/../../tools/assets/help/cds-help.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds watch --help" ${proj} > ${dir}/../../tools/assets/help/cds-watch.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds add --help" ${proj} > ${dir}/../../tools/assets/help/cds-add.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds compile --help" ${proj} > ${dir}/../../tools/assets/help/cds-compile.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds env --help" ${proj} > ${dir}/../../tools/assets/help/cds-env.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds init --help" ${proj} > ${dir}/../../tools/assets/help/cds-init.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds repl --help" ${proj} > ${dir}/../../tools/assets/help/cds-repl.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds watch --help" ${proj} > ${dir}/../../tools/assets/help/cds-watch.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds version" ${proj} > ${dir}/../../tools/assets/help/cds-version.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds version --markdown" ${proj} > ${dir}/../../tools/assets/help/cds-version-md.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds env requires.db" ${proj} > ${dir}/../../tools/assets/help/cds-env-requires-db.out.md
Expand Down
2 changes: 1 addition & 1 deletion get-started/in-a-nutshell.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ cds db/schema.cds -2 yml
cds db/schema.cds -2 sql
```

[Learn more about the command line interface by executing `cds help`.](#cli){.learn-more}
[Learn more about the command line interface by executing `cds help`.](../tools/cds-cli#cds-help){.learn-more}



Expand Down
4 changes: 3 additions & 1 deletion node.js/cds-compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ It supports different variants based on the type of the first argument `model` a
Depending on the variants, the method returns a Promise or a sync value.
### Compiling `.cds` files (async)
If the first argument is either a string starting with `"file:"`, or an _array_ of filenames, these files are read and compiled to a single CSN asynchronously:
Expand All @@ -53,6 +52,9 @@ let csn = await cds.compile ('file:db')

> The given filenames are resolved to effective absolute filenames using [`cds.resolve`](#cds-resolve).
> [!TIP] Use <code>cds compile</code> as CLI equivalent
> The [`cds compile` CLI](../tools/cds-cli#cds-compile) is available as entry point to the functions described here. For example, `cds compile --to hana` maps to `cds.compile.to.hana` etc.


### Single in-memory sources
Expand Down
130 changes: 130 additions & 0 deletions tools/assets/help/cds-compile.out.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<!-- this file is automatically generated and updated by a github action -->
<pre class="log">
> cds compile --help

<strong>SYNOPSIS</strong>
<em>cds compile</em> &lt;models&gt; [&lt;options&gt;]

Compiles the specified models to CSN format, applying processors to unfold
and generate target outputs using the &lt;options&gt;.


<strong>OPTIONS</strong>

<em>-2</em> | <em>--to</em> &lt;target format&gt;

Compiles the given models to the specified &lt;target format&gt;.
Currently supported:

- json, yml
- edm, edmx, edmx-v2, edmx-v4, edmx-w4, edmx-x4
- sql, hdbcds, hdbtable, hana
- cdl
- xsuaa
- openapi
- asyncapi

<em>-4</em> | <em>--for</em> &lt;target&gt;

Unfolds the compiled CSN for the specified &lt;target&gt; usages,
or get a comma-separated list, without generating target formats.
Currently supported:

- odata
- sql

<em>--dialect</em> &lt;dialect&gt;

Needs option <em>--to</em>.
Specify the dialect in combination with <em>--to sql</em>.
Currently supported:

- sqlite
- h2
- postgres
- hana

<em>-s</em> | <em>--service</em> &lt;name&gt; | all

Chooses a specific service or <i>all</i> to force output for all services.
The service name must be fully qualified, including the namespace, if any.

<em>-l</em> | <em>--lang</em> &lt;languages&gt; | all

Localizes the output with given &lt;languages&gt;, a comma-separated list
of language/locale codes or <i>all</i>.
Localization is carried out before all other processors (-4/u) or backends (-2).

<em>-o</em> | <em>--dest</em> &lt;folder&gt;

Writes output to the given folder instead of stdout.

<em>-f</em> | <em>--flavor</em> sources | files | parsed | xtended | inferred

Depending on the argument, returns a model with the given level of detail:

sources: paths and content of all resolved source files
files: paths of all effectively referenced files
parsed: the definitions and extensions, without applying the
extensions or includes, and without imported definitions.
xtended: the definitions with all imports and extensions resolved,
but without any derived information
inferred: the effective model, including imported definitions, extensions,
and derived information. This is the default flavor.

<em>--parse</em>

Shortcut for '--flavor parsed'

<em>--plain</em>

Shortcut for '--flavor xtended'

<em>--docs</em>

Preserves /**...*/ doc comments in 'doc' properties of CSN outputs,
as well as in 'Core.Description' annotations of EDMX outputs.

<em>--locations</em>

Preserves $location properties of CSN outputs.

<em>--log-level</em> debug | info | warn | error

Chooses which level of compiler messages to log. The default log-level is <em>warn</em>.

<em>--openapi:url</em> &lt;Server URL for Open API export&gt;

The server URL used in the generated OpenAPI document. The default is the service
base path as declared in the CDS source.
Use the ${service-path} variable to have the service path included in the URL.

<em>--openapi:servers</em> &lt;Stringified JSON Object for Open API export&gt;

The servers definition used in the generated OpenAPI document. <em>--openapi:url</em> is
ignored when this option is specified.

<em>--odata-version</em> 4.0|4.01

Adds the OData version's functionality of the input CDS/CSN file to the generated OpenAPI document.

<em>--openapi:diagram</em>

Include YUML diagram in the generated OpenAPI document, default: <em>false</em>.

<em>--openapi:config-file</em> filename

The passed configuration file will be read to generate the OpenAPI document, incorporating all specified options.
Precedence of Options: Inline options specified in the command line will take precedence over those defined in the configuration file.

<em>--asyncapi:merged</em>

A single AsyncAPI document is generated using the details of all input services. Information of <i>title</i>
and <i>version</i> should be provided as preset.

<strong>EXAMPLES</strong>
<em>cds</em> compile model.cds
<em>cds</em> c model.json --to sql
<em>cds</em> srv -s all -l all -2 edmx -o out
<em>cds</em> compile srv -s sap.sample.TestService -2 asyncapi -o out
</pre>
46 changes: 46 additions & 0 deletions tools/assets/help/cds-env.out.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!-- this file is automatically generated and updated by a github action -->
<pre class="log">
> cds env --help

<strong>SYNOPSIS</strong>
<em>cds env</em> [&lt;key&gt;] [&lt;options&gt;]

<strong>EXPLANATION</strong>
Displays the effective configuration for the given key, or all of the
current environment.

<strong>OPTIONS</strong>
<em>--sources</em>

Lists the sources from with the current env has been compiled.

<em>-k</em> | <em>--keys</em>

Prints (top-level) keys of matching properties only

<em>-p</em> | <em>--properties</em>
<em>-l</em> | <em>--list</em>

Prints output in .properties format

<em>-j</em> | <em>--json</em>

Prints output in JSON format

<em>-r</em> | <em>--raw</em>

Prints output with minimum formatting or decoration

<em>-4</em> | <em>--for</em> | <em>--profile</em> &lt;profile,...&gt;

Load configuration for the specified profile(s).
The <em>development</em> profile is used by default.

<em>-P</em> | <em>--process-env</em>

Show properties from Node.js <i>process.env</i>.

<em>-b</em> | <em>--resolve-bindings</em>

Resolve remote service bindings configured via <em>cds bind</em>.
</pre>
90 changes: 90 additions & 0 deletions tools/assets/help/cds-init.out.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!-- this file is automatically generated and updated by a github action -->
<pre class="log">
> cds init --help

<strong>SYNOPSIS</strong>
<em>cds init</em> [&lt;project&gt;] [&lt;options&gt;]

Initializes a new project in folder ./&lt;project&gt;, with the current
working directory as default.

<strong>OPTIONS</strong>
<em>--java</em>

Create a CAP Java project.

<em>--add</em> &lt;feature | comma-separated list of features&gt;

Add one or more features while creating the project.
&lt;feature&gt; can be one of the following:

<em>completion</em> - shell completion for cds commands
<em>java</em> - creates a Java-based project
<em>nodejs</em> - creates a Node.js-based project
<em>esm</em> - ESM-compatible Node.js project
<em>tiny-sample</em> - add minimal sample files
<em>sample</em> - add sample files including Fiori UI
<em>typer</em> - type generation for CDS models
<em>typescript</em> - add minimum configuration for a bare TypeScript project
<em>handler</em> - handler stubs for service entities, actions and functions
<em>mta</em> - Cloud Foundry deployment using mta.yaml
<em>cf-manifest</em> - Cloud Foundry deployment using manifest files
<em>helm</em> - Kyma deployment using Helm charts
<em>helm-unified-runtime</em> - Kyma deployment using Unified Runtime Helm charts
<em>containerize</em> - containerization using ctz CLI
<em>multitenancy</em> - schema-based multitenancy support
<em>toggles</em> - allow dynamically toggled features
<em>extensibility</em> - tenant-specific model extensibility
<em>side-by-side-extensibility</em> - logic extensibility via extension points
<em>mtx</em> - multitenancy + toggles + extensibility
<em>xsuaa</em> - authentication via XSUAA
<em>ias</em> - authentication via IAS
<em>ams</em> - authorization via AMS
<em>hana</em> - database support for SAP HANA
<em>postgres</em> - database support for PostgreSQL
<em>sqlite</em> - database support for SQLite
<em>h2</em> - database support for H2
<em>liquibase</em> - database migration using Liquibase
<em>redis</em> - SAP BTP Redis, Hyperscaler Option
<em>attachments</em> - SAP BTP Object Store Service
<em>malware-scanner</em> - SAP Malware Scanning Service
<em>local-messaging</em> - messaging via local event bus
<em>file-based-messaging</em> - messaging via file system
<em>enterprise-messaging</em> - messaging via SAP Enterprise Messaging
<em>enterprise-messaging-shared</em> - messaging via shared SAP Enterprise Messaging
<em>redis-messaging</em> - messaging via Redis
<em>kafka</em> - messaging via Apache Kafka
<em>approuter</em> - dynamic routing using @sap/approuter
<em>connectivity</em> - SAP BTP Connectivity Service
<em>destination</em> - SAP BTP Destination Service
<em>html5-repo</em> - SAP BTP HTML5 Application Repository
<em>portal</em> - SAP BTP Portal Service
<em>application-logging</em> - SAP BTP Application Logging Service
<em>audit-logging</em> - SAP BTP Audit Logging Service
<em>notifications</em> - SAP BTP Notification Service
<em>workzone-standard</em> - SAP BTP Work Zone, Standard Edition
<em>data</em> - add CSV headers for modeled entities
<em>http</em> - add .http files for modeled services
<em>lint</em> - configure cds lint
<em>pipeline</em> - CI/CD pipeline integration

<em>--java:mvn</em> &lt;Comma separated maven archetype specific parameters&gt;

Add the given parameters to the archetype call.
See <i>https://cap.cloud.sap/docs/java/developing-applications/building#the-maven-archetype</i>
for parameters supported by the archetype.

<em>--force</em>

Overwrite all files.

<strong>EXAMPLES</strong>
<em>cds init</em> bookshop
<em>cds init</em> bookshop --java
<em>cds init</em> bookshop --add hana
<em>cds init</em> bookshop --add multitenancy,mta
<em>cds init</em> --java --java:mvn groupId=myGroup,artifactId=newId,package=my.company

<strong>SEE ALSO</strong>
<em>cds add</em> - to augment your projects later on
</pre>
8 changes: 8 additions & 0 deletions tools/assets/help/cds-watch.out.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
Specify file extensions to watch for in a comma-separated list.
<em>Example:</em> cds w --ext cds,json,js.

<em>--include</em> &lt;paths,...&gt;

Comma-separated list of additional paths to watch.

<em>--exclude</em> &lt;paths,...&gt;

Comma-separated list of additional paths to ignore.

<em>--livereload</em> &lt;port | false&gt;

Specify the port for the livereload server. Defaults to '35729'.
Expand Down
18 changes: 17 additions & 1 deletion tools/cds-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Use `cds help` to see an overview of all commands:

Use `cds help <command>` or `cds <command> ?` to get specific help:

<!--@include: ./assets/help/cds-watch.out.md-->
<!--@include: ./assets/help/cds-repl.out.md-->


## cds init
Expand All @@ -102,6 +102,9 @@ For example to create a project with a sample bookshop model and configuration f
cds init --add sample,hana
```

::: details See the full help text of `cds init`
<!--@include: ./assets/help/cds-init.out.md -->
:::


## cds add
Expand Down Expand Up @@ -362,9 +365,22 @@ Use `cds env` to inspect currently effective config settings:

<!--@include: ./assets/help/cds-env-requires-db.out.md -->

::: details See the full help text of `cds env`
<!--@include: ./assets/help/cds-env.out.md -->
:::


## cds compile

Compiles the specified models to [CSN](../cds/csn) or other formats.

[See simple examples in the getting started page](../get-started/in-a-nutshell#cli).{.learn-more}

[For the set of built-in compile 'formats', see the `cds.compile.to` API](../node.js/cds-compile#cds-compile-to).{.learn-more}


In addition, the following formats are available:

### mermaid <Since version="8.0.0" of="@sap/cds-dk" /> {.compile}

This produces text for a [Mermaid class diagram](https://mermaid.js.org/syntax/classDiagram.html):
Expand Down

0 comments on commit f0f2189

Please sign in to comment.