aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/main.rs
blob: f179c524474b89a6245ac351940c039fa1147b84 (plain)
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
29
30
//! ref: composer/bin/composer

use shirabe::console::Application;
use shirabe::util::Platform;
use shirabe_php_shim::{realpath, run_shutdown_functions};

fn main() {
    // TODO(php-runtime): the full initialization process in composer/bin/composer should be ported
    // somewhere else that communicates with the real PHP runtime.

    Platform::put_env(
        "COMPOSER_BINARY",
        &realpath(&std::env::args().next().unwrap_or_default()).unwrap_or_default(),
    );

    // run the command application
    let application = match Application::new_shared("Composer".to_string(), String::new()) {
        Ok(application) => application,
        Err(e) => {
            eprintln!("{}", e);
            std::process::exit(1);
        }
    };
    let result = Application::run(&application, None, None);
    run_shutdown_functions();
    if let Err(e) = result {
        eprintln!("{}", e);
        std::process::exit(1);
    }
}