duritong / trocla

A password store for password creation and retrieval
Other
75 stars 18 forks source link

support multiple options #11

Closed asquelt closed 10 years ago

asquelt commented 10 years ago

in https://github.com/duritong/trocla/blob/master/bin/trocla#L106 remaining ARGV is taken as :other_options but when module is called only 1st element is taken with shift.

there is apparently no way to provide more than 1 option to module (and ie. for x509 module i need plenty).

i've changed it to

options[:other_options] = [ ARGV.join("\n") ]

which works, but it's ugly, so i'm not pulling it.

duritong commented 10 years ago

Sorry for not coming back earlier.

The idea of the last argument, is that you can specify a simple yaml parseable string, which is then expanded before handing over to trocla-core.

See https://github.com/duritong/trocla/blob/master/bin/trocla#L45

Primarly we need that to be able to pass any kind of structured data to formats, without having to let trocla-core know about the requirements for that format.

See the last part of https://github.com/duritong/trocla#create as an example or the following idea:

$ ruby -ryaml -e 'puts YAML.load(ARGV[0]).inspect' "{ a: 1, b: 2}"
{"a"=>1, "b"=>2}

so for trocla:

$ trocla create my_cert x509pub '{ alt_name: myhost }'

As a rough example.

Would this format fit for you? Do you have a better idea to still keep the flexibility? Also note that the second argument to the def format(plain_password,options={}) is always a hash, which can be filled with additional information for that format.

I would be very interested in more formats (especially a x509 one!), so if you think that this is feasible or do you see a nice solution for the issue.

Don't hesitate to post here further, I will be able to address your questions much faster now.

asquelt commented 10 years ago

that seems to do the trick. i've missed curly brackets trick to inline yaml.

duritong commented 10 years ago

Only for one-item hashes this works without brackets:

$ ruby -ryaml -e 'puts YAML.load(ARGV[0]).inspect' 'user: a'
{"user"=>"a"}

So I'm happy to close the issue and looking forward to your x509 format pull request! :-)