Class: AdLocalize::OptionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/ad_localize/option_handler.rb

Class Method Summary collapse

Class Method Details

.parse!(options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ad_localize/option_handler.rb', line 3

def self.parse!(options)
  option_parser = OptionParser.new do |parser|
    parser.banner = "Usage: exe/ad_localize [options] file(s)"

    parser.on("-d", "--debug", TrueClass, "Run in debug mode")
    parser.on("-e", "--export-all-sheets", TrueClass,
              "                Export all sheets from spreadsheet specified by --drive-key option.\n                \\tBy default, generates one export directory per sheet (see -m|--merge-sheets option to merge them).\n                \\tAn GCLOUD_CLIENT_SECRET environment variable containing the client_secret.json content is needed.\n    DOC\n    )\n    parser.on(\"-h\", \"--help\", \"Prints help\") do\n      puts parser\n      exit\n    end\n    parser.on(\"-k\", \"--drive-key SPREADSHEET_ID\", String, \"Use google drive spreadsheets\")\n    parser.on(\"-m\", \"--merge-policy POLICY\", String,\n              <<~DOC\n                Merge specified csv (or sheets from --export-all) instead of exporting each csv.\n                \\treplace: if a key is already defined, replace its value.\n                \\tkeep: if a key is already defined, keep the previous value.\n    DOC\n    )\n    parser.on(\"-o\", \"--only PLATFORMS\", Array, \"PLATFORMS is a comma separated list. Only generate localisation files for the specified platforms. Supported platforms : \#{Requests::ExportRequest::SUPPORTED_PLATFORMS.to_sentence}\")\n    parser.on(\"-s\", \"--sheets SHEET_IDS\", Array, \"SHEET_IDS is a comma separated list. Use a specific sheet id for Google Drive spreadsheets with several sheets\")\n    parser.on(\"-t\", \"--target-dir PATH\", String, \"Path to the target directory\")\n  end\n\n  args = {}\n  option_parser.parse!(options, into: args)\n  args[:csv_paths] = options\n  return args\nend\n"