Class: Leetcoder::Commands
- Inherits:
-
Object
- Object
- Leetcoder::Commands
- Includes:
- Helpers::Utils
- Defined in:
- lib/leetcoder/leetcoder/commands.rb
Constant Summary collapse
- DOWNLOAD_TYPE_ONE =
:one- DOWNLOAD_TYPE_ALL =
:all
Constants included from Helpers::Utils
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#define_commands(parser) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
-
#initialize(options = {}) ⇒ Commands
constructor
A new instance of Commands.
- #run! ⇒ Object
Methods included from Helpers::Utils
#create_directory, #create_file, #lang_to_ext, #store_cookie
Constructor Details
#initialize(options = {}) ⇒ Commands
14 15 16 |
# File 'lib/leetcoder/leetcoder/commands.rb', line 14 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/leetcoder/leetcoder/commands.rb', line 12 def @options end |
Instance Method Details
#define_commands(parser) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
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 54 55 56 57 |
# File 'lib/leetcoder/leetcoder/commands.rb', line 22 def define_commands(parser) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize parser. = 'Usage: leetcoder [commands]' parser.separator '' parser.separator '* indicates default value' parser.separator '' parser.separator 'commands:' parser.on( '-d', '--download [TYPE]', [DOWNLOAD_TYPE_ALL, DOWNLOAD_TYPE_ONE], 'Specify number of accepted submission to download per problem (*one, all)' ) do |type| [:download_type] = type || DOWNLOAD_TYPE_ONE end parser.on('-c', '--cookie', String, 'Input Leetcode Cookie') do exit end parser.on('-f', '--folder FOLDER_PATH', String, 'Specify download folder location (* <current_directory>/leetcode)') do |folder| [:download_folder] = File.(folder) end parser.on_tail('-v', '--version', 'Show version') do puts Leetcoder::VERSION exit end parser.on_tail('-h', '--help', 'Show available commands') do puts parser exit end end |