Skip to main content

oxide_cli/
lib.rs

1pub mod addons;
2pub mod auth;
3pub mod cache;
4pub mod cli;
5pub mod completions;
6pub mod config;
7pub mod paths;
8pub mod templates;
9pub mod upgrade;
10pub mod utils;
11
12use std::{
13  path::PathBuf,
14  sync::{Arc, Mutex},
15};
16
17use reqwest::Client;
18
19use crate::paths::OxidePaths;
20
21pub type CleanupState = Arc<Mutex<Option<PathBuf>>>;
22
23pub struct AppContext {
24  pub paths: OxidePaths,
25  pub client: Client,
26  pub cleanup_state: CleanupState,
27  pub backend_url: String,
28  pub frontend_url: String,
29}
30
31impl AppContext {
32  pub fn new(paths: OxidePaths, client: Client, cleanup_state: CleanupState) -> Self {
33    let backend_url = std::env::var("OXIDE_BACKEND_URL")
34      .unwrap_or_else(|_| "https://oxide-server.onrender.com".to_string());
35    let frontend_url = std::env::var("OXIDE_FRONTEND_URL")
36      .unwrap_or_else(|_| "https://oxide-cli.vercel.app".to_string());
37    Self {
38      paths,
39      client,
40      cleanup_state,
41      backend_url,
42      frontend_url,
43    }
44  }
45}