Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --casing Option to ExportCommand #359

Closed
rannn505 opened this issue Feb 11, 2024 · 1 comment · Fixed by #362
Closed

Add --casing Option to ExportCommand #359

rannn505 opened this issue Feb 11, 2024 · 1 comment · Fixed by #362
Assignees
Labels
feat New feature or request

Comments

@rannn505
Copy link
Contributor

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`,
    }),
@RonConfigu
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants