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.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#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 |
#paths ⇒ Object
Returns the value of attribute paths
12 13 14 |
# File 'lib/rosette/client/commands/pull_command.rb', line 12 def paths @paths 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 46 47 48 49 50 51 52 53 |
# File 'lib/rosette/client/commands/pull_command.rb', line 13 def self.from_argv(argv, repo, terminal) = { paths: '' } 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 desc = 'The paths to use to restrict the export to only phrases ' + 'found at those paths. Should be pipe-separated.' opts.on('-p paths', '--paths paths', desc) do |path| [:paths] = path.strip end end parser.parse(argv) [:ref] = repo.rev_parse(argv[0] || repo.get_head) (, terminal) new( [:ref], [:file_pattern], [:serializer], [:paths] ) end |
.validate_options!(options, terminal) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rosette/client/commands/pull_command.rb', line 55 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 |