diff --git a/Cargo.lock b/Cargo.lock index ef7226c..fa23687 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1059,7 +1059,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "oseda-cli" -version = "2.6.2" +version = "2.7.0" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index a78ffe2..dd042b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://oseda.net" repository = "https://github.com/oseda-dev/oseda-cli" readme = "README.md" name = "oseda-cli" -version = "2.6.2" +version = "2.7.0" edition = "2021" [[bin]] diff --git a/Usage.md b/Usage.md index a6b7b3a..0ed32e1 100644 --- a/Usage.md +++ b/Usage.md @@ -11,6 +11,7 @@ This document contains the help content for the `oseda` command-line program. * [`oseda deploy`↴](#oseda-deploy) * [`oseda fork`↴](#oseda-fork) * [`oseda export`↴](#oseda-export) +* [`oseda update`↴](#oseda-update) ## `oseda` @@ -26,6 +27,7 @@ oseda project scafolding CLI * `deploy` — Deploy your Oseda project to github to add to oseda.net * `fork` — Fork the library repository to submit your course * `export` — Export the Oseda project to a PDF file This will install the npm package `decktape` This relies on a chromium backend, as a result, it may take a while to run +* `update` — Update the oseda binary from crates.io @@ -104,6 +106,14 @@ Export the Oseda project to a PDF file This will install the npm package `deckta +## `oseda update` + +Update the oseda binary from crates.io + +**Usage:** `oseda update` + + +
diff --git a/src/bin/oseda.rs b/src/bin/oseda.rs index 330bbd1..e91dd15 100644 --- a/src/bin/oseda.rs +++ b/src/bin/oseda.rs @@ -7,7 +7,7 @@ use oseda_cli::{ deploy::{self}, export::{self}, fork::{self}, - init, run, + init, run, update, }, Cli, Commands, }; @@ -34,6 +34,10 @@ fn main() { Commands::Fork => fork::fork(), Commands::Export(options) => export::export(options.clone()) .map(|_| println!("Successfully export project to {0}", options.port)), + Commands::Update => update::update().map(|_| { + println!("Successfully updated oseda"); + println!("You may need to restart the shell for updates to take effect") + }), }; // little annoying, but makes the exit code match what users would expect diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index d63b2d2..344a04d 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -4,3 +4,4 @@ pub mod export; pub mod fork; pub mod init; pub mod run; +pub mod update; diff --git a/src/cmd/update.rs b/src/cmd/update.rs new file mode 100644 index 0000000..ad0502f --- /dev/null +++ b/src/cmd/update.rs @@ -0,0 +1,18 @@ +use std::{ + error::Error, + process::{Command, Stdio}, +}; + +pub fn update() -> Result<(), Box> { + let status = Command::new("cargo") + .args(["install", "oseda-cli"]) + .stdout(Stdio::inherit()) + .stdin(Stdio::inherit()) + .status()?; + + if !status.success() { + return Err(format!("Error: exit status {}", status).into()); + } + + Ok(()) +} diff --git a/src/lib.rs b/src/lib.rs index 1ffca8b..ddb94b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,4 +38,6 @@ pub enum Commands { /// This will install the npm package `decktape` /// This relies on a chromium backend, as a result, it may take a while to run Export(cmd::export::ExportOptions), + /// Update the oseda binary from crates.io + Update, }