|
1 | | -import { Command, EnumType, ValidationError } from '@cliffy/command' |
| 1 | +import { Command, EnumType } from '@cliffy/command' |
2 | 2 |
|
3 | 3 | import { Engine, EngineConfiguration, EnginePlatform, EngineTarget } from '../../lib/engine.ts' |
4 | 4 | import { createProject } from '../../lib/project.ts' |
5 | 5 | import type { GlobalOptions } from '../../lib/types.ts' |
6 | 6 | import { Config } from '../../lib/config.ts' |
7 | 7 |
|
8 | | -export type CompileOptions = typeof compile extends Command<void, void, infer Options, infer Argument, GlobalOptions> |
| 8 | +export type CleanOptions = typeof clean extends Command<void, void, infer Options, infer Argument, GlobalOptions> |
9 | 9 | ? Options |
10 | 10 | : never |
11 | 11 |
|
12 | | -export const compile = new Command<GlobalOptions>() |
13 | | - .description('Compile a project') |
| 12 | +export const clean = new Command<GlobalOptions>() |
| 13 | + .description('Cleans the output of a target build') |
| 14 | + .type('Target', new EnumType(EngineTarget)) |
14 | 15 | .type('Configuration', new EnumType(EngineConfiguration)) |
15 | 16 | .type('Platform', new EnumType(EnginePlatform)) |
16 | | - .option('-p, --platform <platform:Platform>', 'Platform', { default: Engine.getCurrentPlatform() }) |
17 | | - .option('-c, --configuration <configuration:Configuration>', 'Configuration', { |
| 17 | + .arguments('<target:Target> [ubtArgs...]') |
| 18 | + .option('--projected', 'Add the -project argument. Defaults to true', { default: true }) |
| 19 | + .option('-p, --platform <platform:Platform>', 'Platform to build, defaults to host platform', { |
| 20 | + default: Engine.getCurrentPlatform(), |
| 21 | + }) |
| 22 | + .option('-c, --configuration <configuration:Configuration>', 'Configuration to build, defaults to Development', { |
18 | 23 | default: EngineConfiguration.Development, |
19 | 24 | }) |
20 | 25 | .option('--dry-run', 'Dry run', { default: false }) |
21 | | - .arguments('<target:string>') |
22 | | - .action(async (options, target = EngineTarget.Editor) => { |
23 | | - const { platform, configuration, dryRun } = options as CompileOptions |
| 26 | + .stopEarly() |
| 27 | + .action(async (options, target = EngineTarget.Editor, ...ubtArgs: Array<string>) => { |
| 28 | + const { platform, configuration, dryRun, projected } = options as CleanOptions |
| 29 | + |
24 | 30 | const config = Config.getInstance() |
25 | 31 | const { engine: { path: enginePath }, project: { path: projectPath } } = config.mergeConfigCLIConfig({ |
26 | 32 | cliOptions: options, |
27 | 33 | }) |
28 | 34 | const project = await createProject(enginePath, projectPath) |
| 35 | + |
29 | 36 | await project.compile({ |
30 | 37 | target: target as EngineTarget, |
31 | 38 | configuration: configuration as EngineConfiguration, |
32 | 39 | platform: platform as EnginePlatform, |
33 | 40 | dryRun: dryRun, |
| 41 | + clean: true, |
| 42 | + projected: projected, |
| 43 | + extraArgs: ubtArgs, |
34 | 44 | }) |
35 | 45 | }) |
0 commit comments