bin/flex-station in flex-station-data-1.0.0 vs bin/flex-station in flex-station-data-1.0.1
- old
+ new
@@ -1,16 +1,37 @@
#!/usr/bin/env ruby
require "pathname"
+require "flex_station_data/concerns/callable"
-case command = ARGV.first
-when "sample-data"
- system(Pathname(__dir__).join("flex-station-sample-data").to_path, *ARGV.drop(1))
-when "linear-regression"
- system(Pathname(__dir__).join("flex-station-linear-regression").to_path, *ARGV.drop(1))
-when nil
- $stderr.puts "USAGE: flex-station <command>"
- exit(1)
-else
- $stderr.puts "Unrecognised command: #{command}"
- exit(1)
+class App
+ include FlexStationData::Concerns::Callable[:run]
+
+ attr_reader :command, :args
+
+ def initialize(command = "help", *args)
+ @command = command
+ @args = args
+ end
+
+ def dir_path
+ Pathname(__dir__)
+ end
+
+ def linear_regression_path
+ dir_path.join("flex-station-linear-regression")
+ end
+
+ def run
+ case command
+ when "linear-regression"
+ exec(linear_regression_path.to_path, *args)
+ when "help", "--help"
+ puts "USAGE: flex-station <command>"
+ else
+ $stderr.puts "Unrecognised command: #{command}"
+ exit(1)
+ end
+ end
end
+
+App.run(*ARGV)