# frozen_string_literal: true

require "clamp"

module Makit
  module Cli
    # Define the 'nuget_cache' subcommand
    #
    # nuget_cache Google.Protobuf
    # nuget_cache Google.Protobuf 3.27.2
    class NugetCacheCommand < Clamp::Command
      parameter "PACKAGE", "The package id", attribute_name: :package, required: true
      parameter "VERSION", "The package version", attribute_name: :version, default: nil

      def execute
        if version.nil?
          # look up the latest version of the package
          raise "TODO: implement latest version lookup"
        end

        # download the package
        url = "https://www.nuget.org/api/v2/package/#{package}/#{version}"
        if !url.nil?
          # download the package

          raise "TODO: implement package download"
          puts "url: #{url}"
          puts "relative directoyr: #{Makit::Environment.get_relative_directory(url)}"
          puts "work directory: #{Makit::Environment.get_work_directory(url)}"
        end
        puts "TODO: implement work command"
      end
    end

    def install_cache_package(package, version)
    end
  end
end