class Bootsnap::CLI

def parser

def parser
  @parser ||= OptionParser.new do |opts|
    opts.banner = "Usage: bootsnap COMMAND [ARGS]"
    opts.separator ""
    opts.separator "GLOBAL OPTIONS"
    opts.separator ""
    help = <<~HELP
      Path to the bootsnap cache directory. Defaults to tmp/cache
    HELP
    opts.on("--cache-dir DIR", help.strip) do |dir|
      self.cache_dir = dir
    end
    help = <<~HELP
      Print precompiled paths.
    HELP
    opts.on("--verbose", "-v", help.strip) do
      self.verbose = true
    end
    help = <<~HELP
      Number of workers to use. Default to number of processors, set to 0 to disable multi-processing.
    HELP
    opts.on("--jobs JOBS", "-j", help.strip) do |jobs|
      self.jobs = Integer(jobs)
    end
    opts.separator ""
    opts.separator "COMMANDS"
    opts.separator ""
    opts.separator "    precompile [DIRECTORIES...]: Precompile all .rb files in the passed directories"
    help = <<~HELP
      Precompile the gems in Gemfile
    HELP
    opts.on("--gemfile", help) { self.compile_gemfile = true }
    help = <<~HELP
      Path pattern to not precompile. e.g. --exclude 'aws-sdk|google-api'
    HELP
    opts.on("--exclude PATTERN", help) { |pattern| exclude_pattern(pattern) }
    help = <<~HELP
      Disable ISeq (.rb) precompilation.
    HELP
    opts.on("--no-iseq", help) { self.iseq = false }
    help = <<~HELP
      Disable YAML precompilation.
    HELP
    opts.on("--no-yaml", help) { self.yaml = false }
    help = <<~HELP
      Disable JSON precompilation.
    HELP
    opts.on("--no-json", help) { self.json = false }
  end
end