Sha256: 4f3fa42115d74590b34efcb431b54e12864fbbfcb822445561db1c7962b7ba01

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require("fileutils")

class Fancy {
  class Compiler Command {
    def self option: argv flag: name {
      argv delete(name)
    }

    def self option: argv value: name {
      idx = argv index(name)
      if: idx then: {
        value = argv delete_at(idx + 1)
        argv delete_at(idx)
        value
      } else: {
        nil
      }
    }

    def self run: argv {
      batch = option: argv flag: "--batch"
      print = option: argv flag: "-B"
      src_path = option: argv value: "--source-path"
      out_path = option: argv value: "--output-path"
      argv each() |f| {
        o = nil
        if: (out_path && src_path) then: {
          o = f sub(src_path, out_path) + "c"
        }
        compile: f to: o info: batch print: print
      }
      if: batch then: {
        size = argv size()
        files = "file"
        { files = files + "s" } if: (size > 1)
        "Compiled " ++ (argv size) ++ " " ++ files ++ "." . println
      }
    }

    def self compile: file to: to (nil) info: info (false) print: print (false) {
      if: info then: {
        "Compiling " ++ file println
      }
      if: to then: {
        FileUtils mkdir_p(File dirname(to))
      }
      Compiler compile_file: file to: to line: 1 print: print
    }
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fancy-0.10.0 lib/compiler/command.fy
fancy-0.9.0 lib/compiler/command.fy