From fd2f4f819070572e0761f1f4275e2eba93d89375 Mon Sep 17 00:00:00 2001 From: Harri Lehtisaari Date: Tue, 21 Feb 2017 09:33:46 +0200 Subject: [PATCH] create a separate parse_arguments to use in push,pull and dump --- init.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init.rb b/init.rb index aa9e995..a89e71f 100644 --- a/init.rb +++ b/init.rb @@ -33,6 +33,7 @@ def index def pull puts "Remote database (Heroku) to local database" local_database_setup(ARGV) + parse_arguments(ARGV) database_url = get_remote_database(true) if database_url.nil? puts "Error: Heroku database URL not defined" @@ -50,6 +51,7 @@ def push return unless prompt == 'y' local_database_setup(ARGV) + parse_arguments(ARGV) database_url = get_remote_database(true) if database_url.nil? puts "Error: Heroku database URL not defined" @@ -61,6 +63,7 @@ def push end def dump + parse_arguments(ARGV) database_url = get_remote_database(false) if database_url.nil? puts "Error: Heroku database URL not defined" @@ -114,7 +117,9 @@ def local_database_setup(arguments) # Treat argument as database name @@local_database['database'] = arguments[1] end + end + def parse_arguments(arguments) opts = GetoptLong.new( [ '--search', '-s', GetoptLong::OPTIONAL_ARGUMENT ], [ '--replace', '-r', GetoptLong::OPTIONAL_ARGUMENT ],