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 'config' command #19

Open
melriffe opened this issue Sep 25, 2020 · 4 comments
Open

Add 'config' command #19

melriffe opened this issue Sep 25, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request tty TTY Toolkit related

Comments

@melriffe
Copy link
Member

This command serves two purposes:

  1. to generate a blank configuration file
  2. to load a configuration file

Secondarily, and this might go in a separate ticket/milestone, add sub-commands to add/edit a config file.

I will need to document the order in which configuration items are processed.

@melriffe melriffe self-assigned this Sep 25, 2020
@melriffe melriffe added enhancement New feature or request tty TTY Toolkit related labels Sep 25, 2020
@melriffe melriffe added this to the v0.2.0 Release milestone Sep 25, 2020
@melriffe
Copy link
Member Author

I'm going to change this ticket's goals. This will not be a new command. The app will be modified to create a new 'default' configuration file when one does not already exist.

I'm going to change TTY::Config to only look in the user's home directory. But... and this is the second change, I'm going to add a global option/flag/argument that allows a user to specify a different configuration file.

If I can't get TTY::Config to place nicely with those requirements I will kick it to the curb.

@melriffe
Copy link
Member Author

I believe, though, the path forward is to make Hammerhead.configuration receive its configuration object rather than build one. This way, I can inject the configuration into the tool.

At least that's the goal.

@melriffe
Copy link
Member Author

melriffe commented Nov 1, 2020

I just made Hammerhead::Configuration.config settable. And I think the reason I want something injectable is because I hope to be able to support command-line, ENV, and configuration file settings. I think I'll need a unified configuration object that is injected into Hammerhead::Configuration.

I'm vacillating between simple and complex - I might opt for simple and only go to complex when needed - which I don't need right now.

@piotrmurach
Copy link
Contributor

The tty-config can read and write configuration in many formts including handling of env variables. It stores everything in a deeply nested hash. So, for example, you can read arbitrarily complex configuration options from users. Let's say you can config add command that takes the setting and value:

hammerhead config add a.b.c 1

Then you can invoke set on the tty-config instance:

config.set("a.b.c", value: "1")

Which will result in the following configuration hash:

 # => {a: {b: {c: "1"}}}

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

No branches or pull requests

2 participants