#!/usr/bin/env ruby # frozen_string_literal: true require 'pathname' require 'pry' source_path = File.expand_path("#{Pathname.new(__FILE__).dirname}/../lib") $LOAD_PATH << source_path require 'rails_app_generator' if ARGV.empty? puts 'Please provide a profile for the new application' puts puts 'See --help for more info' exit 0 elsif %w[-v --version].include? ARGV[0] puts RailsAppGenerator::VERSION exit 0 end RailsAppGenerator::Cli.start(ARGV) exit 0 # # Use RAG with in the same way as the Rails generator (the following commands should be equivalent) # # rails new args # # rag new args # if ARGV.first == 'new' # # NOTE: This is not yet working # RailsAppGenerator::Cli::Standard.start ARGV[1..] # exit 0 # elsif ARGV.first == 'diff' # # args, opts = Thor::Arguments.split(ARGV[1..]) # RailsAppGenerator::Cli::Diff.start(ARGV[1..]) # , { lhs: true, rhs: true, compare: true } ) # exit 0 # elsif ARGV.first == 'diff_lhs' # RailsAppGenerator::Cli::Diff.start(ARGV[1..], { lhs: true }) # exit 0 # elsif ARGV.first == 'diff_rhs' # RailsAppGenerator::Cli::Diff.start(ARGV[1..], { rhs: true }) # exit 0 # elsif ARGV.first == 'diff_compare' # RailsAppGenerator::Cli::Diff.start(ARGV[1..], { compare: true }) # exit 0 # elsif !ARGV.first.nil? # profile_path = File.expand_path("#{Pathname.new(__FILE__).dirname}/../profiles") # profile_name = ARGV[0] # profile_name += '.json' unless profile_name.end_with?('.json') # profile_file = File.join(profile_path, profile_name) # RailsAppGenerator::Cli::Profile.start(profile_file) # exit 0 # end # if File.exist?(profile_file) # puts "Using profile #{profile_file}" # profile = JSON.parse(File.read(profile_file), symbolize_names: true) # args = profile[:args] # opts = profile[:opts] # rails_options = RailsAppGenerator::RailsOptions.new(opts) # instance = RailsAppGenerator::Starter.new(args) # FileUtils.rm_rf(instance.target_path) # instance.start(rails_options) # else # puts "Profile #{profile_file} not found" # exit 1