<commit_before>require "optparse"
require "ostruct"

require "bento/common"
require "bento/build"
require "bento/delete"
require "bento/normalize"
require "bento/release"
require "bento/revoke"
require "bento/test"
require "bento/upload"

class Options
  NAME = File.basename($PROGRAM_NAME).freeze

  def self.parse(args)
    options = OpenStruct.new
    options.template_files = calculate_templates("**/*.json")

    global = OptionParser.new do |opts|
      opts.banner = "Usage: #{NAME} [SUBCOMMAND [options]]"
      opts.separator ""
      opts.separator <<-COMMANDS.gsub(/^ {8}/, "")
        build        :   build one or more templates
        help         :   prints this help message
        list         :   list all templates in project
        normalize    :   normalize one or more templates
        test         :   test one or more builds with kitchen
        upload       :   upload one or more builds to Vagrant Cloud and S3
        release      :   release a version of a box on Vagrant Cloud
        revoke       :   revoke a version of a box on Vagrant Cloud
        delete       :   delete a version of a box from Vagrant Cloud
      COMMANDS
    end

    # @tas50: commenting this out since it's unused 11/30/2018
    # platforms_argv_proc = proc { |opts|
    #   opts.platforms = builds["public"] unless args.empty?
    # }

    templates_argv_proc = proc { |opts|
      opts.template_files = calculate_templates(args) unless args.empty?

      opts.template_files.each do |t|
        unless File.exist?("#{t}.json")
          warn "File #{t}.json does not exist for template '#{t}'"
          exit(1)
        end
      end
    }

    box_version_argv_proc = proc { |opts|
      opts.box = ARGV[0]
      opts.version = ARGV[1]
    }

    md_json_argv_proc = proc { |opts|
      opts.md_json = ARGV[0]
    }

    subcommand = {
      help: {
        parser: OptionParser.new {},
        argv: proc { |_opts|
          puts global
          exit(0)
        },
      },
      build: {
        class: BuildRunner,
        parser: OptionParser.new do |opts|
          opts.banner = "Usage: #{NAME} build [options] TEMPLATE[ TEMPLATE ...]"

          opts.on("-n", "--dry-run", "Dry run (what would happen)") do |opt|
            options.dry_run = opt
          end

          opts.on("-c BUILD_YML", "--config BUILD_YML", "Use a configuration file") do |opt|
            options.config = opt
          end

          opts.on("-d", "--[no-]debug", "Run packer with debug output") do |opt|
            options.debug = opt
          end

          opts.on("-o BUILDS", "--only BUILDS", "Only build some Packer builds") do |opt|
            options.only = opt
          end

          opts.on("-e BUILDS", "--except BUILDS", "Build all Packer builds except these") do |opt|
            options.except = opt
          end

          opts.on("-m MIRROR", "--mirror MIRROR", "Look for isos at MIRROR") do |opt|
            options.mirror = opt
          end

          opts.on("-C cpus", "--cpus CPUS", "# of CPUs per provider") do |opt|
            options.cpus = opt
          end

          opts.on("-M MEMORY", "--memory MEMORY", "Memory (MB) per provider") do |opt|
            options.mem = opt
          end<commit_msg>Add examples to help<commit_after>require "optparse"
require "ostruct"

require "bento/common"
require "bento/build"
require "bento/delete"
require "bento/normalize"
require "bento/release"
require "bento/revoke"
require "bento/test"
require "bento/upload"

class Options
  NAME = File.basename($PROGRAM_NAME).freeze

  def self.parse(args)
    options = OpenStruct.new
    options.template_files = calculate_templates("**/*.json")

    global = OptionParser.new do |opts|
      opts.banner = "Usage: #{NAME} [SUBCOMMAND [options]]"
      opts.separator ""
      opts.separator <<-COMMANDS.gsub(/^ {8}/, "")
        build        :   build one or more templates
        help         :   prints this help message
        list         :   list all templates in project
        normalize    :   normalize one or more templates
        test         :   test one or more builds with kitchen
        upload       :   upload one or more builds to Vagrant Cloud and S3
        release      :   release a version of a box on Vagrant Cloud
        revoke       :   revoke a version of a box on Vagrant Cloud
        delete       :   delete a version of a box from Vagrant Cloud
      COMMANDS
    end

    # @tas50: commenting this out since it's unused 11/30/2018
    # platforms_argv_proc = proc { |opts|
    #   opts.platforms = builds["public"] unless args.empty?
    # }

    templates_argv_proc = proc { |opts|
      opts.template_files = calculate_templates(args) unless args.empty?

      opts.template_files.each do |t|
        unless File.exist?("#{t}.json")
          warn "File #{t}.json does not exist for template '#{t}'"
          exit(1)
        end
      end
    }

    box_version_argv_proc = proc { |opts|
      opts.box = ARGV[0]
      opts.version = ARGV[1]
    }

    md_json_argv_proc = proc { |opts|
      opts.md_json = ARGV[0]
    }

    subcommand = {
      help: {
        parser: OptionParser.new {},
        argv: proc { |_opts|
          puts global
          exit(0)
        },
      },
      build: {
        class: BuildRunner,
        parser: OptionParser.new do |opts|
          opts.banner = "Usage: #{NAME} build [options] TEMPLATE[ TEMPLATE ...]"

          opts.on("-n", "--dry-run", "Dry run (what would happen)") do |opt|
            options.dry_run = opt
          end

          opts.on("-c BUILD_YML", "--config BUILD_YML", "Use a configuration file") do |opt|
            options.config = opt
          end

          opts.on("-d", "--[no-]debug", "Run packer with debug output") do |opt|
            options.debug = opt
          end

          opts.on("-o BUILDS", "--only BUILDS", "Only build some Packer builds (ex: parallels-iso,virtualbox-iso,vmware-iso)") do |opt|
            options.only = opt
          end

          opts.on("-e BUILDS", "--except BUILDS", "Build all Packer builds except these (ex: parallels-iso,virtualbox-iso,vmware-iso)") do |opt|
            options.except = opt
          end

          opts.on("-m MIRROR", "--mirror MIRROR", "Look for isos at MIRROR") do |opt|
            options.mirror = opt
          end

          opts.on("-C cpus", "--cpus CPUS", "# of CPUs per provider") do |opt|
            options.cpus = opt
          end

          opts.on("-M MEMORY", "--memory MEMORY", "Memory (MB) per provider") do |opt|
            options.mem = opt
          end
{'fraction_non_alphanumeric': 0.11596408461421397, 'fraction_numerical': 0.005174250494597474, 'mean_word_length': 1.9444444444444444, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2921716', 'n_tokens_mistral': 2056, 'n_tokens_neox': 1997, 'n_words': 602}