Add `--casing` Option to `ExportCommand`
rannn505 opened this issue · comments
Suggestion
Introduce a --casing
flag to the ExportCommand
in the Configu CLI, enabling users to adjust the casing convention of configuration keys in the export results. The flag is optional and accepts various casing options, all presented in pascalCase
:
CamelCase
: Transforms keys totwoWords
CapitalCase
: Transforms keys toTwo Words
ConstantCase
: Transforms keys toTWO_WORDS
DotCase
: Transforms keys totwo.words
KebabCase
: Transforms keys totwo-words
NoCase
: Transforms keys totwo words
PascalCase
: Transforms keys toTwoWords
PascalSnakeCase
: Transforms keys toTwo_Words
PathCase
: Transforms keys totwo/words
SentenceCase
: Transforms keys toTwo words
SnakeCase
: Transforms keys totwo_words
TrainCase
: Transforms keys toTwo-Words
Each option will transform the casing of config keys in the output according to the selected style.
Example Usage:
configu eval ... | configu export --casing "snakeCase"
In the above command, if a Config Key is named databaseURL
, applying the --casing "snakeCase"
flag will transform it to database_url
in the export result. This feature caters to developers and systems requiring specific key formatting, such as environment variables in UNIX systems which commonly use UPPER_SNAKE_CASE
, or JavaScript projects that prefer camelCase
for object keys.
This addition will not only streamline the configuration management process but also reduce manual post-processing efforts, making Configu an even more powerful tool in the hands of developers.
Motivation
Offering the --casing
option empowers developers to tailor the format of config keys to align with project standards or the requirements of different deployment targets. This capability simplifies configuration management and deployment processes, especially when working across diverse platforms.
Context
The change-case
library, a part of the project's dependencies, provides the functionality necessary for implementing the casing transformations.
https://www.npmjs.com/package/change-case
casing: Flags.string({
description: `Transforms the casing of Config Keys in the export result to camelCase, PascalCase, Capital Case, snake_case, param-case, CONSTANT_CASE and others`,
}),
Development Plan
- Research
- Add example to examples in
cli/commands/export.ts
- Add
casing
flag toconfigu export
- Create function
applyCasing(result: ExportResult):ExportResult
-> This func will apply the desired casing if one is provided and supported - Update docs (if necessary)