Class: SchemaFerry::CLI
- Inherits:
-
Object
- Object
- SchemaFerry::CLI
- Includes:
- Support::DropDetectable
- Defined in:
- lib/schema_ferry/cli.rb
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
"Ferryfile"- COMMANDS =
%w[apply dry-run].freeze
Constants included from Support::DropDetectable
Support::DropDetectable::DROP_LINE
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv) ⇒ Object
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr) ⇒ CLI
Returns a new instance of CLI.
12 13 14 15 16 |
# File 'lib/schema_ferry/cli.rb', line 12 def initialize(stdout: $stdout, stderr: $stderr) @stdout = stdout @stderr = stderr @allow_drops = true end |
Instance Method Details
#run(argv) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/schema_ferry/cli.rb', line 18 def run(argv) args = parser.parse(argv) return print_and_succeed(parser.to_s) if @mode == :help return print_and_succeed(VERSION) if @mode == :version command = args.first return usage_error("missing command") if command.nil? return usage_error("unknown command: #{command}") unless COMMANDS.include?(command) run_command(command) rescue Error, OptionParser::ParseError => e @stderr.puts "schema_ferry: #{e.}" 1 end |