Coder Social home page Coder Social logo

Comments (17)

bitwalker avatar bitwalker commented on July 22, 2024

@johnfoconnor So so sorry man, I somehow completely missed this issue. I finally (thank god) have time to dive back in to my Elixir projects...work has been out of control for 2 months straight :(. I'll try and get to this one tonight.

from conform.

johnfoconnor avatar johnfoconnor commented on July 22, 2024

I was considering tackling this myself but i couldnt think of a reasonable way to handle delimiting the keys. I suppose you could just escape the . with a backslash but im not sure how you can specify the key data type. especially if the keypath has keys of different types. What are you thinking of?

from conform.

bitwalker avatar bitwalker commented on July 22, 2024

I've got to go back and re-assess the code around that before I know for sure what I think a good solution would be. Do you have any rough ideas of what you think would be workable? Off the top of my head I'm not sure either. I think the first priority is definitely the need for non-atom key support, since I think that likely also addresses the first problem of keys containing ..

from conform.

stocks29 avatar stocks29 commented on July 22, 2024

I'm running into a similar issue using conform for a phoenix project. Trying to override settings from config.exs with myapp.conf ends up resulting in the following effective configuration (per mix conform.effective)

phoenix: [{Elixir,
   [MyApp: [Router: [catch_errors: true, cookies: true,
      debug_errors: false, error_controller: MyApp.ErrorController,
      host: "myapp.mydomain.com", port: 4000,
      session_key: "_myapp_key",
      session_secret: "some-session-secret",
      ssl: false, static_assets: true]]]},
  {MyApp.Router,
   [port: nil, ssl: false, static_assets: true, cookies: true,
    session_key: "_myapp_key",
    session_secret: "other-session-secret",
    catch_errors: true, debug_errors: false,
    error_controller: MyApp.ErrorController]},
  {:code_reloader, [enabled: false]}]]

Just throwing out ideas, but how about using elixir syntax to accomplish this. For example:

atom containing ".":

phoenix.:"MyApp.Router".port = 4000

arbitrary string:

myapp."some arbitrary string".port = 4000

That is kind of noisy though. Another option might be some sort of surrounding characters, like parens or backticks:

atom containing ".":

phoenix.(MyApp.Router).port = 4000

arbitrary string:

myapp.("some arbitrary string").port = 4000

from conform.

bitwalker avatar bitwalker commented on July 22, 2024

Would it be enough to treat Pascal-cased keys as a contiguous atom? For example, phoenix.MyApp.Router.port = 4000 would become phoenix: [{MyApp.Router, [port: 4000]}]. I can't think of any examples where that breaks down off the top of my head, but I don't trust myself in that respect. What are your thoughts @johnfoconnor / @stocks29?

from conform.

stocks29 avatar stocks29 commented on July 22, 2024

I do like the simplicity. It could be seen as a little magical and not quite intuitive though, since the rule would be roughly "if there are two or more contiguous PascalCased keys, they will be merged into a single atom key." This is a special case treated differently from all other lower keys. That said, I think it handles the common case well which is the important piece so it could be seen as very intuitive.

The only downside I see is that it's no longer possible to purposely nest these atoms, although I think that is likely more of an edge case that could be worked around with a less elegant syntax if a valid use case arose. That is, if one had intended myapp.Pascal1.Pascal2.foo = 100 to evaluate to myapp: [{Pascal1: [{Pascal2: [foo: 100]}]}]. I don't have a valid use case for why someone might do this though.

from conform.

stocks29 avatar stocks29 commented on July 22, 2024

@bitwalker here is a pull request to address the myapp.Module.Name.key issue: #17

from conform.

bitwalker avatar bitwalker commented on July 22, 2024

@stocks29 I'll merge this once I've had a chance to hear what @johnfoconnor thinks about it. As we discussed it's a bit magical, but I'm not sure what a better solution would be at this point. As long as everyone else feels ok with it, I am.

from conform.

stocks29 avatar stocks29 commented on July 22, 2024

@bitwalker sounds good. I obviously didn't solve the string key issue mentioned in this ticket. I can't think of an elegant way to do that unfortunately without explicitly putting quotes in or similar. Could that be accomplished with translations?

Or perhaps adding a "final_translation" concept which allows you to define a function that receives the entire merged config and make modifications before it is written out.

from conform.

yrashk avatar yrashk commented on July 22, 2024

Any updates on this? I am also running into this issue.

from conform.

bitwalker avatar bitwalker commented on July 22, 2024

@yrashk Are you running into the string key issue specifically? If so, I'll probably work on adding support for quoted keys to the conf grammar.

@stocks29 What do you think about the above? So to use string-based keys, you'd do someapp."some arbitrary key" = foo?

from conform.

yrashk avatar yrashk commented on July 22, 2024

I was running into the Camel.Case keys issue

from conform.

stocks29 avatar stocks29 commented on July 22, 2024

@bitwalker I think that seems reasonable and straight-forward.

from conform.

bitwalker avatar bitwalker commented on July 22, 2024

@stocks29 Could you test with master and let me know what issues, if any, you run in to? Quoted keys are now supported in the parser.

from conform.

smpallen99 avatar smpallen99 commented on July 22, 2024

Here is part of my config that is causing issues:

 login_defaults: [
    {"/orange", "[email protected]"},
    {"/orange/monitor", "[email protected]"},
  ],
  phone_number_order: [
    {"Primary Phone", "1"},
    {"Secondary Phone", "2"},
  ]

I would even be happy if I could do the following in my schema:

myapp.settings.phone_number_order: [
...
  default: [
    {"Primary Phone", "1"},
    {"Secondary Phone", "2"}
  ]

from conform.

martin-langhoff avatar martin-langhoff commented on July 22, 2024

Dupe with #47 , or just major overlap ?

from conform.

bitwalker avatar bitwalker commented on July 22, 2024

Lists with arbitrary subtypes are now working properly in master, please open a new issue if there are any problems.

from conform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.