configu / configu

Open-source ConfigOps infrastructure ⚙️

Home Page:https://configu.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 to twoWords
  • CapitalCase: Transforms keys to Two Words
  • ConstantCase: Transforms keys to TWO_WORDS
  • DotCase: Transforms keys to two.words
  • KebabCase: Transforms keys to two-words
  • NoCase: Transforms keys to two words
  • PascalCase: Transforms keys to TwoWords
  • PascalSnakeCase: Transforms keys to Two_Words
  • PathCase: Transforms keys to two/words
  • SentenceCase: Transforms keys to Two words
  • SnakeCase: Transforms keys to two_words
  • TrainCase: Transforms keys to Two-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 to configu export
  • Create function applyCasing(result: ExportResult):ExportResult -> This func will apply the desired casing if one is provided and supported
  • Update docs (if necessary)

Questions / Requests

Notes / Comments / Additional