feature/smbcloud-deploy
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | use { |
| 2 | serde::{Deserialize, Serialize}, |
| 3 | wasm_bindgen::prelude::wasm_bindgen, |
| 4 | }; |
| 5 | |
| 6 | #[derive(clap::ValueEnum, Clone, Copy, Serialize, Deserialize)] |
| 7 | #[wasm_bindgen] |
| 8 | pub enum Environment { |
| 9 | Dev, |
| 10 | Production, |
| 11 | } |
| 12 | |
| 13 | impl std::fmt::Display for Environment { |
| 14 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 15 | write!(f, "{}", self.to_str()) |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | impl std::str::FromStr for Environment { |
| 20 | type Err = (); |
| 21 | |
| 22 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 23 | match s.to_lowercase().as_str() { |
| 24 | "dev" => Ok(Environment::Dev), |
| 25 | "production" => Ok(Environment::Production), |
| 26 | _ => Err(()), |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | impl Environment { |
| 32 | pub fn to_str(&self) -> &str { |
| 33 | match self { |
| 34 | Environment::Dev => "dev", |
| 35 | Environment::Production => "production", |
| 36 | } |
| 37 | } |
| 38 | pub fn smb_dir(&self) -> String { |
| 39 | match self { |
| 40 | Environment::Dev => ".smb-dev".to_string(), |
| 41 | Environment::Production => ".smb".to_string(), |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | pub fn api_protocol(&self) -> String { |
| 46 | match self { |
| 47 | Environment::Dev => "http".to_string(), |
| 48 | Environment::Production => "https".to_string(), |
| 49 | } |
| 50 | } |
| 51 | pub fn api_host(&self) -> String { |
| 52 | match self { |
| 53 | Environment::Dev => "localhost:8088".to_string(), |
| 54 | Environment::Production => "api.smbcloud.xyz".to_string(), |
| 55 | } |
| 56 | } |
| 57 | } |