Sha256: 275923bf92d074f3bd67e0b6ad40836874d4d95eb09273c178809bdae0eee275

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
## My Velib Querrier

require 'velibe'

case ARGV[0]
  when /f(av(orite)?)?$/  # handle favorites
    stations = ARGV[2..-1] || []
    force = ARGV[2..-1].any? { |s| /-(f|-force)/ }

    case ARGV[1]
      when /a(dd)?/
        stations, wrong_arg = stations.partition { |n| n =~ /\d+/ }
        puts "BEWARE: '#{wrong_arg.join(', ')}' are not stations number and where ignored" unless wrong_arg.empty?
        Velibe.add_favorite(stations)
      when /setup|reset/
        if Velibe.reset_favorites(force)
          puts 'Favorites Stations were reset'
        else
          puts 'Favorites not empty, you need to add --force/-f flag if you really want to reset'
        end
      else
        Velibe.print_favorites
    end

  when /setup/ # setup database
    force = ARGV[1] =~ /-(f|-force)/
    Velibe.setup_station_database(force)
    Velibe.reset_favorites(force)

  else # just Query stations
    stations, wrong_arg = ARGV.partition { |n| n =~ /\d+/ }  # LATER: check station really exist
    puts "BEWARE: '#{wrong_arg.join(', ')}' are not stations number and were ignored" unless wrong_arg.empty?
    Velibe.print_stations(stations)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
velibe-0.2.3 bin/velibe
velibe-0.2.2 bin/velibe
velibe-0.2.1 bin/velibe