Skip to content

infer environment variable name similar to how variables names are inferred (ie from long form option) #117

Open
@ebertech

Description

@ebertech

Hi

Long time listener, first time caller.

I'm wondering if anyone is opposed to having the ability to have:

option %w{--beep-boop}, "VALUE", "the beep and the boop", :environment_variable => true

translate to

option %w{--beep-boop}, "VALUE", "the beep and the boop", :environment_variable => "BEEP_BOOP"

the algorithm for which would be taking doing

def environment_variable
  @environment_variable ||= attribute_name.upcase
end

plus allowing overrides via the traditional way as to not break existing stuff. This would be similar to how delegate is done in rails

https://apidock.com/rails/Module/delegate

Or if there's a smarter way to do this because I find myself either making a "Concern" that does this automagically or manually translating the name and upcasing it. Both of which seem...unrubyish.

I'm more than happy to provide code and tests and such, I was just making sure this hadn't been considered and discarded previously. In which case apologies for wasting your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions