lib/sportdb/cli/main.rb in sportdb-1.5.0 vs lib/sportdb/cli/main.rb in sportdb-1.6.0

- old
+ new

@@ -17,12 +17,12 @@ require 'sportdb/cli/opts' LogUtils::Logger.root.level = :info # set logging level to info program :name, 'sportdb' -program :version, SportDB::VERSION -program :description, "sport.db command line tool, version #{SportDB::VERSION}" +program :version, SportDb::VERSION +program :description, "sport.db command line tool, version #{SportDb::VERSION}" # default_command :help default_command :load @@ -45,11 +45,11 @@ http://geraldb.github.com/sport.db =end ## todo: find a better name e.g. change to settings? config? safe_opts? why? why not? -myopts = SportDB::Opts.new +myopts = SportDb::Opts.new ### global option (required) ## todo: add check that path is valid?? possible? global_option '-i', '--include PATH', String, "Data path (default is #{myopts.data_path})" @@ -60,11 +60,11 @@ ### todo/fix: just want --debug/--verbose flag (no single letter option wanted) - fix global_option '-w', '--verbose', "Show debug messages" def connect_to_db( options ) - puts SportDB.banner + puts SportDb.banner puts "working directory: #{Dir.pwd}" db_config = { :adapter => 'sqlite3', @@ -89,13 +89,13 @@ LogUtils::Logger.root.level = :debug if options.verbose.present? myopts.merge_commander_options!( options.__hash__ ) connect_to_db( myopts ) - LogDB.create - WorldDB.create - SportDB.create + LogDb.create + WorldDb.create + SportDb.create puts 'Done.' end # action end # command create command :setup do |c| @@ -125,29 +125,29 @@ ## todo: check order for reference integrity # not really possible to delete world data if sport data is present # delete sport first if options.delete.present? - SportDB.delete! if options.sport.present? - WorldDB.delete! if options.world.present? + SportDb.delete! if options.sport.present? + WorldDb.delete! if options.world.present? end if options.world.present? - WorldDB.read_all( myopts.world_data_path ) + WorldDb.read_all( myopts.world_data_path ) end if options.sport.present? - SportDB.read_setup( "setups/#{setup}", myopts.data_path ) + SportDb.read_setup( "setups/#{setup}", myopts.data_path ) end else # assume "plain" regular setup - LogDB.create - WorldDB.create - SportDB.create + LogDb.create + WorldDb.create + SportDb.create - WorldDB.read_all( myopts.world_data_path ) - SportDB.read_setup( "setups/#{setup}", myopts.data_path ) + WorldDb.read_all( myopts.world_data_path ) + SportDb.read_setup( "setups/#{setup}", myopts.data_path ) end puts 'Done.' end # action end # command setup @@ -165,25 +165,25 @@ LogUtils::Logger.root.level = :debug if options.verbose.present? myopts.merge_commander_options!( options.__hash__ ) connect_to_db( myopts ) - SportDB.delete! if options.delete.present? + SportDb.delete! if options.delete.present? - reader = SportDB::Reader.new + reader = SportDb::Reader.new( myopts.data_path ) args.each do |arg| name = arg # File.basename( arg, '.*' ) if myopts.event.present? ## fix: rename to load_event_fixtures_w... or similar - reader.load_fixtures( myopts.event, name, myopts.data_path ) + reader.load_fixtures( myopts.event, name ) else ## fix> add a convenience method for loading single fixture ary = [] ary << name - reader.load( ary, myopts.data_path ) + reader.load( ary ) end end # each arg puts 'Done.' end @@ -199,11 +199,11 @@ LogUtils::Logger.root.level = :debug if options.verbose.present? myopts.merge_commander_options!( options.__hash__ ) connect_to_db( myopts ) - LogDB::Models::Log.all.each do |log| + LogDb::Models::Log.all.each do |log| puts "[#{log.level}] -- #{log.msg}" end puts 'Done.' end @@ -219,11 +219,11 @@ LogUtils::Logger.root.level = :debug if options.verbose.present? myopts.merge_commander_options!( options.__hash__ ) connect_to_db( myopts ) - SportDB.tables + SportDb.tables puts 'Done.' end end @@ -237,10 +237,10 @@ LogUtils::Logger.root.level = :debug if options.verbose.present? myopts.merge_commander_options!( options.__hash__ ) connect_to_db( myopts ) - SportDB.props + SportDb.props puts 'Done.' end end