# frozen_string_literal: true require "clamp" module Makit module Cli # Define the 'new' subcommand class NewCommand < Clamp::Command AVAILABLE_TYPES = %w[gem crate nuget].freeze option "--list", :flag, "List available types" option ["-o", "--output"], "OUTPUT_DIR", "Specify output directory", default: "." option ["-t", "--type"], "TYPE", "Type of the new entity", default: "gem" parameter "TYPE", "Type of the new entity", attribute_name: :type, required: false parameter "NAME", "Name of the new entity", attribute_name: :name, required: false parameter "DIRECTORY", "The output directory", attribute_name: :name, required: false def execute if list? puts "Available types:" AVAILABLE_TYPES.each { |t| puts " - #{t}" } else if type.nil? || name.nil? puts "Error: TYPE and NAME are required unless using --list" exit(1) end unless AVAILABLE_TYPES.include?(type) puts "Error: '#{type}' is not a valid type. Use --list to see available types." exit(1) end puts "Creating a new #{type} named #{name}." end end end end end