Class: LeechtopDownloader::CLI

Inherits:
Thor
  • Object
show all
Extended by:
T::Sig
Includes:
CLIHelpers
Defined in:
lib/leechtop_downloader/cli.rb

Overview

CLI is the Thor application for handling commands.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CLIHelpers

#acquire_lock, #fix_encoding, #lock_path_for, #skip_download?, #skip_locked, #with_app_lock

Class Method Details

.exit_on_failure?T::Boolean

Ensure Thor exits with an error status on failure.

Returns:

  • (T::Boolean)

    true



19
20
21
# File 'lib/leechtop_downloader/cli.rb', line 19

def self.exit_on_failure?
  true
end

Instance Method Details

#download(*urls) ⇒ Object

LT-REQ-001, LT-REQ-002 Main entry point to download files.

Parameters:

  • urls (Array<String>)

    The URLs or file paths to download from.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/leechtop_downloader/cli.rb', line 29

def download(*urls)
  if urls.empty?
    puts 'Error: You must provide at least one URL or file path.'
    exit 1
  end

  with_app_lock do
    skip_existing = options.fetch(:skip_existing, true)
    destination = options.fetch(:destination, '.')

    urls.each { |arg| process_argument(arg, skip_existing, destination) }
  end
end