   app.commandLine.appendSwitch 'ppapi-flash-path', flashPath
 
 
-exports.parseCLIArg = ->
+exports.parseCLIArg = parseCLIArg
 exports.loadFlashPlayer = load
 exports.getFlashPlayerVersion = getFlashVersion
 exports.getAllVersions = getAllVersions

{app} = require 'electron'
{join} = require 'path-extra'
fs = require 'fs-extra'

platform = process.platform
filename = switch platform

getAllVersions = ->
  new FlashPlayerVersions getBuiltInFlashPath(), findChromeFlashPath(), findSystemFlashPath()

useFlashLoc = 'auto'
CLIFlashPath = ''
reCLIArg = /^--flash-player=(.+)$/i
reUseSpecialPath = /^@(auto|builtin|chrome|system)$/i
parseCLIArg = (arg) ->
  if (m = reCLIArg.exec arg)?
    value = m[1]
    if value.startsWith '@'
      if (m = reUseSpecialPath.exec value)?
        useFlashLoc = m[1]
      else
        error "Unknown flash player location: #{value}"
    else
      if validatePath value
        useFlashLoc = 'cli'
        CLIFlashPath = value
      else
        error "Invalid flash player path:\n#{value}"
    true
  else
    false

getPath = (loc = useFlashLoc) ->
  switch loc
    when 'auto'
      flashPath = getBuiltInFlashPath()
      flashPath ?= findChromeFlashPath()
      flashPath ?= findSystemFlashPath()
      return flashPath
    when 'builtin'
      flashPath = getBuiltInFlashPath()
    when 'chrome'
      flashPath = findChromeFlashPath()
    when 'system'
      flashPath = findSystemFlashPath()
    when 'cli'
      flashPath = CLIFlashPath
  flashPath ?= getPath 'auto'
  flashPath

load = ->
