Module: Haxe::Cli::Proxy::Command

Defined in:
lib/haxe/cli/proxy/command.rb

Defined Under Namespace

Classes: Result

Constant Summary collapse

HAXE =
::Haxe::Cli::Proxy::Constants::HAXE

Class Method Summary collapse

Class Method Details

.compile(options) ⇒ ::Haxe::Cli::Command::Result

Execute haxe compile command.

Parameters:

  • options (Hash)

    compile options. if uses hxml, give option parameter such as…

    {
      hxml: [hxml file name]
    }
    

    if not uses hxml, give option parameter such as…

    {
      main:         [main class name],
      target:       [compile target],
      output:       [output directory or file],
      lib:          [using haxe libraries with array],
      compile_flag: [compile flags with array],
      debug:        [debug mode flag with boolean],
      verbose:      [verbose mode flag with boolean],
      dce:          [dead code elimination option]
    }
    

Returns:

  • (::Haxe::Cli::Command::Result)

    haxe compile command results.



78
79
80
81
# File 'lib/haxe/cli/proxy/command.rb', line 78

def compile(options)
  builder = ::Haxe::Cli::Proxy::CompileOption::Builder.new(options)
  execute "#{HAXE} #{builder}"
end

.exists?boolean

Check whether command haxe exists.

Returns:

  • (boolean)


15
16
17
18
19
20
21
# File 'lib/haxe/cli/proxy/command.rb', line 15

def exists?
  if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/
    system "where #{HAXE} > nul"
  else
    system "hash #{HAXE} 2> /dev/null"
  end
end

.help::Haxe::Cli::Command::Result

Execute command ‘haxe -help`

Returns:

  • (::Haxe::Cli::Command::Result)

    ‘haxe -help` command results.



28
29
30
31
# File 'lib/haxe/cli/proxy/command.rb', line 28

def help
  help = ::Haxe::Cli::Proxy::Constants::OPTION_HELP
  execute "#{HAXE} #{help}"
end

.lib(lib_name, version = nil) ⇒ ::Haxe::Cli::Command::Result

Execute command ‘haxe -lib [lib_name]:`

Parameters:

  • lib_name (String)

    haxe library name.

  • version (String|nil) (defaults to: nil)

    haxe library version.

Returns:

  • (::Haxe::Cli::Command::Result)

    ‘haxe -lib` command results.



40
41
42
43
44
# File 'lib/haxe/cli/proxy/command.rb', line 40

def lib(lib_name, version=nil)
  lib = ::Haxe::Cli::Proxy::Constants::OPTION_LIB
  lib_name << ":#{version}" unless version.nil?
  execute "#{HAXE} #{lib} #{lib_name}"
end

.xml(file) ⇒ ::Haxe::Cli::Command::Result

Execute command ‘haxe -xml [file]`

Parameters:

  • file (String)

    haxe library name.

Returns:

  • (::Haxe::Cli::Command::Result)

    ‘haxe -lib` command results.



52
53
54
55
# File 'lib/haxe/cli/proxy/command.rb', line 52

def xml(file)
  xml = ::Haxe::Cli::Proxy::Constants::OPTION_XML
  execute "#{HAXE} #{xml} #{file}"
end