Class: Rosette::Client::Commands::PullCommandArgs
- Inherits:
-
Struct
- Object
- Struct
- Rosette::Client::Commands::PullCommandArgs
- Defined in:
- lib/rosette/client/commands/pull_command.rb
Instance Attribute Summary collapse
-
#file_pattern ⇒ Object
Returns the value of attribute file_pattern.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#serializer ⇒ Object
Returns the value of attribute serializer.
Class Method Summary collapse
Instance Attribute Details
#file_pattern ⇒ Object
Returns the value of attribute file_pattern
12 13 14 |
# File 'lib/rosette/client/commands/pull_command.rb', line 12 def file_pattern @file_pattern end |
#ref ⇒ Object
Returns the value of attribute ref
12 13 14 |
# File 'lib/rosette/client/commands/pull_command.rb', line 12 def ref @ref end |
#serializer ⇒ Object
Returns the value of attribute serializer
12 13 14 |
# File 'lib/rosette/client/commands/pull_command.rb', line 12 def serializer @serializer end |
Class Method Details
.from_argv(argv, repo, terminal) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rosette/client/commands/pull_command.rb', line 13 def self.from_argv(argv, repo, terminal) = {} parser = OptionParser.new do |opts| desc = "File pattern to use. Can contain these placeholders:\n" + "* %{locale.code}: The full locale code, eg. pt-BR\n" + "* %{locale.territory}: The locale's territory part, eg. 'BR'" + "* %{locale.language}: The locale's language part, eg. 'pt'" opts.on('-f pattern', '--file-pattern pattern', desc) do |pattern| pattern.strip! [:file_pattern] = pattern.empty? ? nil : pattern end desc = 'The serializer to use. Translations will be requested in ' + 'this format.' opts.on('-s serializer', '--serializer serializer', desc) do |serializer| serializer.strip! [:serializer] = serializer.empty? ? nil : serializer end end parser.parse(argv[1..-1]) [:ref] = repo.rev_parse(argv[0] || repo.get_head) (, terminal) new( [:ref], [:file_pattern], [:serializer] ) end |
.validate_options!(options, terminal) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rosette/client/commands/pull_command.rb', line 47 def self.(, terminal) unless .include?(:file_pattern) terminal.say('Please supply a file pattern via the -f option') exit 1 end unless .include?(:serializer) terminal.say('Please supply a serializer via the -s option') exit 1 end end |