#!/usr/bin/env ruby
# SPDX-License-Identifier: MulanPSL-2.0+
# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
# frozen_string_literal: true

require 'optparse'
require_relative '../lib/mail_compare_result.rb'

# mail job results to job submitter
# require the job had submitted job.yaml include email

opt_parser = OptionParser.new do |opts|
  opts.banner = 'Usage: mail-compare  upstream_commit'
  opts.separator 'eg: mail-compare 88247d9d32aa6e49692e76ba19066378fa666e89'
  opts.separator ''
  opts.separator 'options:'

  opts.on_tail('-h', '--help', 'show this message') do
    puts opts
    exit
  end
end

argv = ARGV.empty? ? ['-h'] : ARGV

opt_parser.parse!(argv)

upstream_commit = argv[0]
mail = MailJobResult.new(upstream_commit)
mail.send_mail
