-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New
config
query to inspect flowr configuration (#1230)
* feat(config-query): new config query * doc: document new `@conifg` query
- Loading branch information
1 parent
cd859c2
commit 8f9ef04
Showing
7 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { log } from '../../../util/log'; | ||
import type { | ||
ConfigQuery, | ||
ConfigQueryResult | ||
} from './config-query-format'; | ||
import type { BasicQueryData } from '../../base-query-format'; | ||
import { getConfig } from '../../../config'; | ||
|
||
|
||
export function executeConfigQuery(_: BasicQueryData, queries: readonly ConfigQuery[]): ConfigQueryResult { | ||
if(queries.length !== 1) { | ||
log.warn('Config query expects only up to one query, but got', queries.length); | ||
} | ||
|
||
return { | ||
'.meta': { | ||
/* there is no sense in measuring a get */ | ||
timing: 0 | ||
}, | ||
config: getConfig() | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format'; | ||
import { executeConfigQuery } from './config-query-executor'; | ||
import { bold, type OutputFormatter } from '../../../util/ansi'; | ||
import { printAsMs } from '../../../util/time'; | ||
import Joi from 'joi'; | ||
import type { FlowrConfigOptions } from '../../../config'; | ||
import { jsonReplacer } from '../../../util/json'; | ||
|
||
export interface ConfigQuery extends BaseQueryFormat { | ||
readonly type: 'config'; | ||
} | ||
|
||
export interface ConfigQueryResult extends BaseQueryResult { | ||
readonly config: FlowrConfigOptions; | ||
} | ||
|
||
|
||
export const ConfigQueryDefinition = { | ||
executor: executeConfigQuery, | ||
asciiSummarizer: (formatter: OutputFormatter, _processed: unknown, queryResults: BaseQueryResult, result: string[]) => { | ||
const out = queryResults as ConfigQueryResult; | ||
result.push(`Query: ${bold('config', formatter)} (${printAsMs(out['.meta'].timing, 0)})`); | ||
result.push(` ╰ Config:\n${JSON.stringify(out.config, jsonReplacer, 4)}`); | ||
return true; | ||
}, | ||
schema: Joi.object({ | ||
type: Joi.string().valid('config').required().description('The type of the query.'), | ||
}).description('The config query retrieves the current configuration of the flowR instance.') | ||
} as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters