diff --git a/README.md b/README.md index 51fff4d9..eacc3ee6 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Just run `topgrade`. It will run the following steps: * Update Rustup by running `rustup update`. This will also attempt to run `rustup self update` when Rustup is installed inside the home directory. * Run Cargo [install-update](https://github.com/nabijaczleweli/cargo-update) * Upgrade Emacs packages (You'll get a better output if you have [Paradox](https://github.com/Malabarba/paradox) installed) +* Upgrade [OCaml packages](https://opam.ocaml.org/) * Upgrade Vim/Neovim packages. Works with the following plugin frameworks: * [NeoBundle](https://github.com/Shougo/neobundle.vim) * [Vundle](https://github.com/VundleVim/Vundle.vim) diff --git a/src/generic.rs b/src/generic.rs index 55a56e42..00dac048 100644 --- a/src/generic.rs +++ b/src/generic.rs @@ -94,6 +94,23 @@ pub fn run_rustup(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool) None } +#[must_use] +pub fn run_opam_update(terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> { + if let Some(opam) = utils::which("opam") { + terminal.print_separator("OCaml Package Manager"); + + let success = || -> Result<(), Error> { + Executor::new(&opam, dry_run).arg("update").spawn()?.wait()?.check()?; + Executor::new(&opam, dry_run).arg("upgrade").spawn()?.wait()?.check()?; + Ok(()) + }().is_ok(); + + return Some(("OPAM", success)); + } + + None +} + #[must_use] pub fn run_custom_command(name: &str, command: &str, terminal: &mut Terminal, dry_run: bool) -> Result<(), Error> { terminal.print_separator(name); diff --git a/src/main.rs b/src/main.rs index 3c8a17c6..be14a6b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -204,6 +204,10 @@ fn run() -> Result<(), Error> { |terminal| generic::run_emacs(&base_dirs, terminal, dry_run), &mut terminal, )); + report.push_result(execute( + |terminal| generic::run_opam_update(terminal, dry_run), + &mut terminal, + )); report.push_result(execute( |terminal| vim::upgrade_vim(&base_dirs, terminal, dry_run), &mut terminal,