CDS Command Line Interface (CLI)
To use cds
from your command line, install package @sap/cds-dk
globally:
npm i -g @sap/cds-dk
cds version
Use cds version
to get information about your installed package version:
$ cds version @capire/samples: 2.0.0 @sap/cds: 6.7.0 @sap/cds-compiler: 3.8.2 @sap/cds-dk: 6.7.0 @sap/cds-dk (global): 6.7.0 @sap/cds-mtxs: 1.7.1 @sap/eslint-plugin-cds: 2.6.3 Node.js: v18.13.0 home: .../node_modules/@sap/cds $ cds version --markdown | @capire/samples | https://github.com/sap-samples/cloud-cap-samples.git | | ------------------ | ----------- | | Node.js | v18.13.0 | | @sap/cds | 6.7.0 | | @sap/cds-compiler | 3.8.2 | | @sap/cds-dk | 6.7.0 | | @sap/eslint-plugin | 2.6.3 |
cds add completion requires @sap/cds-dk 7.9.0
The cds
command supports shell completion with the tab key for several shells and operating systems.
For Linux, macOS and Windows use the following command to activate shell completion:
cds add completion
After that, restart your shell (or source the shell configuration) and enjoy shell completion support for all cds
commands.
Currently supported shells:
Operating System | Shell |
---|---|
Linux | bash, zsh |
macOS | bash, zsh |
Windows | PowerShell, Git Bash |
WSL | bash, zsh |
To remove the shell completion, run the following command:
cds completion --remove
Then source or restart your shell.
cds help
Use cds help
to see an overview of all commands:
$ cds help USAGE cds <command> [<args>] cds <src> = cds compile <src> cds = cds help COMMANDS i | init jump-start cds-based projects a | add add a feature to an existing project y | bind bind application to remote services m | import add models from external sources c | compile compile cds models to different outputs p | parse parses given cds models s | serve run your services in local server w | watch run and restart on file changes r | repl read-eval-event loop e | env inspect effective configuration b | build prepare for deployment d | deploy deploy to databases or cloud l | login login to extendable SaaS application t | lint [beta] run linter for env or model checks v | version get detailed version information ? | help get detailed usage information | pull pull base model for a SaaS app extension | push push extension to SaaS app to enable or update it | subscribe subscribe a tenant to a multitenant SaaS app | completion add/remove shell completion for cds commands | mock call cds serve with mocked service Learn more about each command using: cds help <command> or cds <command> --help
Use cds help <command>
or cds <command> ?
to get specific help:
$ cds watch --help SYNOPSIS cds watch [<project>] Tells cds to watch for relevant things to come or change in the specified project or the current work directory. Compiles and (re-)runs the server on every change detected. Actually, cds watch is just a convenient shortcut for: cds serve all --with-mocks --in-memory? OPTIONS --port <number> Specify the port on which the launched server listens. If you specify '0', the server picks a random free port. Alternatively, specify the port using env variable PORT. --ext <extensions> Specify file extensions to watch for in a comma-separated list. Example: cds w --ext cds,json,js. --livereload <port | false> Specify the port for the livereload server. Defaults to '35729'. Disable it with value false. --open <url> Open the given URL (suffix) in the browser after starting. If none is given, the default application URL will be opened. SEE ALSO cds serve --help for the different start options.
cds init
Use cds init
to create new projects.
cds add
Use cds add
to gradually add capabilities ('facets') to projects.
The facets built into @sap/cds-dk
provide you with a large set of standard features that support CAP's grow-as-you-go approach:
Feature | Node.js | Java |
---|---|---|
hana | ✓ | ✓ |
postgres | ✓1 | ✓1 |
liquibase | n/a | ✓ |
h2 | n/a | ✓ |
multitenancy | ✓ | ✓ |
toggles | ✓ | ✓ |
extensibility | ✓ | ✓ |
application-logging | ✓1 | ✓1 |
audit-logging | planned | planned |
html5-repo | ✓ | ✓ |
approuter | ✓ | ✓ |
connectivity | ✓ | ✓ |
data | ✓ | ✓ |
destination | ✓ | ✓ |
enterprise-messaging | ✓ | planned |
enterprise-messaging-shared | ✓ | planned |
redis-messaging | ✓1 | planned |
local-messaging | ✓ | planned |
file-based-messaging | ✓ | planned |
kafka | ✓ | ✓ |
helm | ✓ | ✓ |
helm-unified-runtime | ✓ | ✓ |
mta | ✓ | ✓ |
notifications | ✓ | planned |
pipeline | ✓ | ✓ |
sample | ✓ | ✓ |
tiny-sample | ✓ | ✓ |
sqlite | ✓ | ✓ |
typer | ✓ | n/a |
xsuaa | ✓ | ✓ |
1 Only for Cloud Foundry
cds env
Use cds env
to inspect currently effective config settings:
$ cds env get requires.db { impl: '@sap/cds/libx/_runtime/sqlite/Service.js', credentials: { url: ':memory:' }, kind: 'sqlite' }
cds repl
Use cds repl
to live-interact with Node.js APIs:
$ cds repl Welcome to cds repl v6.7.0 > SELECT.from(Foo) Query { SELECT: { from: { ref: [ 'Foo' ] } } } > cds.requires.db { impl: '@sap/cds/libx/_runtime/sqlite/Service.js', credentials: { url: ':memory:' }, use: [Getter], kind: 'sqlite' }
Debugging with cds watch
Start cds watch
and enter debug
. This restarts the application in debug mode. Similarly, debug-brk
will start debug mode, but pause the application at the first line, so that you can debug bootstrap code.
If you do this in VS Code's integrated terminal with the 'Auto Attach' feature enabled, debugging starts right away. If you executed cds watch
on a standalone terminal, you can still attach a Node.js debugger to the process.
For example:
- In VS Code, use the Debug: Attach to Node Process command.
- In Chrome browser, just open chrome://inspect and click Inspect.