aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/lib.rs')
-rw-r--r--crates/shirabe/src/lib.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/shirabe/src/lib.rs b/crates/shirabe/src/lib.rs
index 1e17b72..4bd52c2 100644
--- a/crates/shirabe/src/lib.rs
+++ b/crates/shirabe/src/lib.rs
@@ -24,3 +24,23 @@ pub mod repository;
pub mod script;
pub mod self_update;
pub mod util;
+
+pub fn run(argv: Vec<String>) -> anyhow::Result<i32> {
+ use crate::console::Application;
+ use crate::util::Platform;
+ use shirabe_external_packages::symfony::console::input::argv_input::ArgvInput;
+ use shirabe_external_packages::symfony::console::input::input_interface::InputInterface;
+
+ // 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",
+ &shirabe_php_shim::realpath(argv.first().map(String::as_str).unwrap_or_default())
+ .unwrap_or_default(),
+ );
+
+ let application = Application::new_shared("Composer".to_string(), String::new())?;
+ let input = std::rc::Rc::new(std::cell::RefCell::new(ArgvInput::new(Some(argv), None)?))
+ as std::rc::Rc<std::cell::RefCell<dyn InputInterface>>;
+ Application::run(&application, Some(input), None)
+}