Sha256: 7b3865b0cce17bd62c445248874a4445ab5b4680cb999e18bea786747764c14f

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require 'colorize'
require 'nsrr/version'

Nsrr::COMMANDS = {
  'c' => :console,
  'd' => :download,
  'u' => :update,
  'v' => :version
}.freeze

# Exposes certain commands for access from the command line.
module Nsrr
  def self.launch(argv)
    send((Nsrr::COMMANDS[argv.first.to_s.scan(/\w/).first] || :help), argv)
  end

  def self.console(argv)
    require 'nsrr/commands/console'
    Nsrr::Commands::Console.start(argv)
  end

  def self.download(argv)
    require 'nsrr/commands/download'
    Nsrr::Commands::Download.run(argv)
  end

  def self.update(argv)
    require 'nsrr/commands/update'
    Nsrr::Commands::Update.start(argv)
  end

  def self.help(_)
    puts <<-EOT

Usage: nsrr COMMAND [ARGS]

The most common nsrr commands are:
  [c]onsole         Load an interactive console to access
                    and download datasets and files
  [d]ownload        Download all or some files in a DATASET
  [u]pdate          Update the nsrr gem
  [v]ersion         Returns the version of nsrr gem

Commands can be referenced by the first letter:
  Ex: `nsrr v`, for version

EOT
    puts 'Read more on the download command here:'
    puts '  ' + 'https://github.com/nsrr/nsrr-gem'.colorize(:blue).on_white.underline
    puts "\n"
  end

  def self.version(_)
    puts "Nsrr #{Nsrr::VERSION::STRING}"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nsrr-0.4.0 lib/nsrr.rb
nsrr-0.4.0.rc lib/nsrr.rb
nsrr-0.4.0.beta1 lib/nsrr.rb
nsrr-0.3.0 lib/nsrr.rb
nsrr-0.3.0.rc lib/nsrr.rb
nsrr-0.3.0.beta2 lib/nsrr.rb
nsrr-0.3.0.beta1 lib/nsrr.rb