about summary refs log tree commit diff
path: root/src/commands/compile.rs
blob: e16b8c87a659b0715339f47e58219a4b90da8e80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::path::PathBuf;

use clap::Clap;

use crate::common::Result;
use crate::compiler::{self, CompilerOptions};

#[derive(Clap)]
pub struct Compile {
    file: PathBuf,

    #[clap(short = 'o')]
    out_file: PathBuf,

    #[clap(flatten)]
    options: CompilerOptions,
}

impl Compile {
    pub fn run(self) -> Result<()> {
        eprintln!(
            ">>> {} -> {}",
            &self.file.to_string_lossy(),
            self.out_file.to_string_lossy()
        );
        compiler::compile_file(&self.file, &self.out_file, &self.options)
    }
}