diff --git a/Cargo.lock b/Cargo.lock index aaaf16e..9fb5543 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -785,6 +785,25 @@ dependencies = [ "serde", ] +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -947,6 +966,17 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "open" +version = "5.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43bb73a7fa3799b198970490a51174027ba0d4ec504b03cd08caf513d40024bc" +dependencies = [ + "is-wsl", + "libc", + "pathdiff", +] + [[package]] name = "openssl" version = "0.10.73" @@ -1000,6 +1030,7 @@ dependencies = [ "clap-markdown", "ctrlc", "inquire", + "open", "reqwest", "serde", "serde_json", @@ -1031,6 +1062,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + [[package]] name = "percent-encoding" version = "2.3.1" diff --git a/Cargo.toml b/Cargo.toml index 2e05b13..47ea091 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ clap = { version = "4.5.38", features = ["derive"] } clap-markdown = "0.1.5" ctrlc = "3.4.7" inquire = "0.7.5" +open = "5.3.3" reqwest = { version = "0.12.20", features = ["blocking"] } serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" diff --git a/src/bin/oseda.rs b/src/bin/oseda.rs index a1f5cde..f942ac3 100644 --- a/src/bin/oseda.rs +++ b/src/bin/oseda.rs @@ -2,9 +2,7 @@ use std::{error::Error, process}; use clap::Parser; use oseda_cli::{Cli, Commands, cmd::{ - check, - deploy::{self}, - init, run, + check, deploy::{self}, fork::{self}, init, run }}; /// CLI entry point @@ -14,18 +12,19 @@ fn main() { // match on every subcommand result let result: Result<(), Box> = match cli.command { Commands::Init(options) => { - init::init(options).map(|_| println!("Successfully initialized oseda project")) - } + init::init(options).map(|_| println!("Successfully initialized oseda project")) + } Commands::Run => run::run() - .map(|_| println!("Successfully ran oseda project")) - .map_err(|e| e.into()), + .map(|_| println!("Successfully ran oseda project")) + .map_err(|e| e.into()), Commands::Check(options) => check::check(options) - .map(|_| println!("Successfully checked oseda project")) - .map_err(|e| e.into()), + .map(|_| println!("Successfully checked oseda project")) + .map_err(|e| e.into()), Commands::Deploy(options) => deploy::deploy(options).map(|_| { - println!("Successfully deployed oseda project"); - println!("See deployment instructions..."); - }), + println!("Successfully deployed oseda project"); + println!("See deployment instructions..."); + }), + Commands::Fork => fork::fork(), }; // little annoying, but makes the exit code match what users would expect diff --git a/src/cmd/fork.rs b/src/cmd/fork.rs new file mode 100644 index 0000000..6a7ab17 --- /dev/null +++ b/src/cmd/fork.rs @@ -0,0 +1,13 @@ +use std::error::Error; + + +pub fn fork() -> Result<(), Box> { + + let fork_url = "https://github.com/oseda-dev/oseda-lib/fork".to_owned(); + + open::that(fork_url.clone()).map_err(|_|{ + format!("Please visit {fork_url} in a browser and fork the oseda-lib repository") + })?; + + Ok(()) +} diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index 6f9c725..845b48d 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -2,3 +2,4 @@ pub mod check; pub mod deploy; pub mod init; pub mod run; +pub mod fork; diff --git a/src/lib.rs b/src/lib.rs index 2057e2c..8581194 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,4 +32,6 @@ pub enum Commands { Check(cmd::check::CheckOptions), /// Deploy your Oseda project to github to add to oseda.net Deploy(cmd::deploy::DeployOptions), + /// Fork the library repository to submit your course + Fork, }