Class: Keystorage::CLI
- Inherits:
-
Object
- Object
- Keystorage::CLI
- Defined in:
- lib/keystorage/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #usage ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/keystorage/cli.rb', line 7 def initialize(argv) @options = Hash.new @options[:file] = DEFAULT_FILE @argv = argv.clone @opt = OptionParser.new @opt.="Usage: keystorage [options] command [command options] args..." @opt.on('--help', 'show this message') { usage; exit } @opt.on('-f FILE','--file=FILE', 'file to store password') { |v| @options[:file] = v; } end |
Class Method Details
.run(argv) ⇒ Object
38 39 40 |
# File 'lib/keystorage/cli.rb', line 38 def run(argv) self.new(argv).execute end |
Instance Method Details
#execute ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/keystorage/cli.rb', line 28 def execute argv = @opt.parse(@argv) command = argv.shift unless command usage;exit end Commands.send(command,argv,@options) end |
#usage ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/keystorage/cli.rb', line 19 def usage puts @opt; puts "Commands:" @commands = ["list","set","get","help"] @commands.each do |m| puts " "+m end end |