#!/usr/bin/env ruby require "crystalruby" require "fileutils" # Define the actions for the commands def init # Define some dummy content for the YAML file yaml_content = <<~YAML # crystalruby configuration file crystal_src_dir: "./crystalruby" crystal_codegen_dir: "generated" log_level: "info" single_thread_mode: false debug: true YAML # Create the file at the root of the current directory File.write("crystalruby.yaml", yaml_content) puts "Initialized crystalruby.yaml file with dummy content." end def install Dir["#{CrystalRuby.config.crystal_src_dir}/**/src"].each do |src_dir| Dir.chdir(src_dir) do if system("shards check") || system("shards update") puts "Shards installed successfully." else puts "Error installing shards." end end end end def clean Dir["#{CrystalRuby.config.crystal_src_dir}/**/src/generated"].each do |codegen_dir| FileUtils.rm_rf(codegen_dir) end Dir["#{CrystalRuby.config.crystal_src_dir}/**/lib"].each do |lib_dir| FileUtils.rm_rf(lib_dir) end end def build # TODO: Iterate through all generated libs and build puts "Build command is not implemented yet." end # Main program if ARGV.empty? puts "Usage: crystalruby [command]" puts "Commands: init, clear, build" exit 1 end case ARGV[0] when "init" init when "clean" clean when "install" install when "build" build else puts "Invalid command: #{ARGV[0]}" end