Skip to content

Commit

Permalink
add command to print the json schema of the config
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed May 3, 2024
1 parent e5f5f73 commit 263e791
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/engine/paima-standalone/src/utils/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { importOpenApiJson, importTsoaFunction } from './import.js';
import type { Template } from './types.js';
import RegisterRoutes, { EngineService } from '@paima/rest';
import { BaseConfigWithoutDefaults } from '@paima/utils/src/config/loading.js';

// Prompt user for input in the CLI
export const userPrompt = (query: string): Promise<string> => {
Expand Down Expand Up @@ -64,6 +65,10 @@ export const argumentRouter = async (): Promise<void> => {
batcherCommand();
break;

case 'gen-config-json-schema':
genConfigSchemaCommand();
break;

default:
helpCommand();
}
Expand Down Expand Up @@ -167,13 +172,18 @@ export const helpCommand = (): void => {
doLog(` help Shows list of commands currently available.`);
doLog(` version Shows the version of used paima-engine.`);
doLog(` batcher Saves the bundled batcher project to your local filesystem.`);
doLog(` gen-config-json-schema Prints the JSON Schema for the engine configuration.`);
};

// Batcher command logic
export const batcherCommand = (): void => {
prepareBatcher();
};

export const configJsonSchema = (): void => {
genConfigSchemaCommand();
};

// Build middleware for specific .env file and launch webserver:
const startWebServer = (): Promise<void> =>
new Promise((resolve, reject) => {
Expand Down Expand Up @@ -249,3 +259,7 @@ const pickGameTemplate = async (templateArg: string): Promise<Template> => {
doLog(`Unknown selection, ${defaultTemplate} will be used.`);
return defaultTemplate;
};

function genConfigSchemaCommand() {
doLog(JSON.stringify(BaseConfigWithoutDefaults));
}

0 comments on commit 263e791

Please sign in to comment.