rubygems / gemstash

A RubyGems.org cache and private gem server
MIT License
754 stars 122 forks source link

Command line config #30

Open smellsblue opened 9 years ago

smellsblue commented 9 years ago

This has been in the back of my head for a while, and has been referenced in #28, so I figured I would put my thoughts here.

Right now, all config is handled via a config file, but it would be neat to support all configuration directly as config options as well.

@indirect suggested -h/--host, -p/--port and -b/--bind, which we could expand to all the config options.

Another route I've thought about was along the lines of ssh config. For example, you can run ssh user@host -o Port=22 or ssh user@host -o "Port 22". You can also use all those config in your ssh config file, just like we would support in Gemstash.

Thus, it might look like this:

$ gemstash start --config bind=tcp://0.0.0.0:4242 --config rubygems_url=https://gemfury.io
$ gemstash start -c bind=tcp://0.0.0.0:4242 -c rubygems_url=https://gemfury.io

Would these command line options override any config found in the configuration file, even if a specific --config-file is provided? I would think yes, the command line should override.

Thoughts?

pcarranza commented 9 years ago

Override, yes, makes sense with the things like the sherpa mode and else.

I also could not find the host to bind to, so I went the binding way, and I think that it actually makes sense to do it that way.

olleolleolle commented 7 years ago

To save a thought here, I'd mention that Thor supports "key:value key2:value2" Hash options, which perhaps we can abuse to get something we can use for the above-mentioned use-case.

Adding a Thor option definition to cli.rb:

    method_option :config, :type => :hash, :desc =>
      "Config options to override when starting key:value key2:value format"

We could perhaps find a way to get it into the Configuration, later.