diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ada5c7..4df780fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). ### Added - `cds.app` typed as express.js application +- `cds.cli` CLI arguments ## Version 0.6.5 - 2024-08-13 ### Fixed diff --git a/apis/facade.d.ts b/apis/facade.d.ts index bb3fb641..366cebd5 100644 --- a/apis/facade.d.ts +++ b/apis/facade.d.ts @@ -29,5 +29,18 @@ export const version: string export const home: string export const root: string +type CliCommands = 'add' | 'build' | 'compile' | 'deploy' | 'import' | 'init' | 'serve' | (string & {}) +/** + * The parsed effective `cds` CLI command and arguments. + * May be undefined if not started from the `cds` CLI. + * @see https://cap.cloud.sap/docs/node.js/cds-facade#cds-cli + */ +export const cli: { + /** Basic command like `serve` */ command?: CliCommands, + /** Positional arguments */ argv?: string[], + /** Named arguments */ options?: Record, +} | undefined + + import { env } from './env' export const requires: env.Requires diff --git a/test/typescript/apis/project/cds.ts b/test/typescript/apis/project/cds.ts index 41dccc72..5a3e6693 100644 --- a/test/typescript/apis/project/cds.ts +++ b/test/typescript/apis/project/cds.ts @@ -4,3 +4,10 @@ cds.version === '1.2.3' cds.home === 'path/to/cds' cds.root === 'path/to/project' cds.requires === cds.env.requires + +cds.cli!.argv = [''] +cds.cli!.options = { foo: true } +cds.cli!.command = 'deploy' +cds.cli!.command = 'unknown-command' +//@ts-expect-error +cds.cli!.command = true