You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No single source of truth — Final values are assembled from multiple parse results
Proposed: Resolver-style API
Similar to GraphQL resolvers, let consumers declare how to resolve values, while configliere handles when and precedence:
constparser=program({name: "testkit",config: commands({run: {
...object({config: {description: "Config file", ...field(z.string().optional())},watch: {description: "Watch mode", ...field(z.boolean().optional())},suite: {description: "Test suite", ...field(z.string())},verbose: {description: "Verbose output", ...field(z.boolean().optional())},}),},}),// Resolver tells configliere how to load file-based valuesresolvers: {file: {// Which parsed field contains the config pathconfigPath: (parsed)=>parsed.config,// How to load the file (generator for Effection)*load(path){constcontent=yield*readFile(path,"utf-8");returnJSON.parse(content);},// Config files are command-scoped: { "run": { ... }}scope: (fileContent,commandName)=>fileContent[commandName],},},});// Single parse - configliere handles everythingconstresult=yield*parser.parse({args: argv,envs: process.env,});// result.value.config.watch - already merged with correct precedence// result.value.config.verbose - includes [file: verbose=true] annotation// Help works consistently regardless of --help position
What configliere would handle internally
Deferred file loading — Parse CLI args first, call resolver to load file, then merge
Problem
Currently, consumers who want to support config file values must implement significant logic outside the parser:
--configpathThis leads to parsing logic "spilling out" into consumer code, duplicating what the parser should own.
Current consumer code pattern
Problems with this approach
--helpposition (see Consistent help behavior regardless of --help position #12)Proposed: Resolver-style API
Similar to GraphQL resolvers, let consumers declare how to resolve values, while configliere handles when and precedence:
What configliere would handle internally
[file: verbose=true]work automatically--helpposition, show sources in helpBenefits
cliValue ?? fileValuemerging--helpworks the same regardless of positionAlternative: Simpler built-in config file option
If the full resolver API is too complex, a simpler built-in config file option could cover the common case: