feature/ruby-runner
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 | #[derive(clap::ValueEnum, Clone, Copy)] |
| 2 | pub enum Environment { |
| 3 | Dev, |
| 4 | Production, |
| 5 | } |
| 6 | |
| 7 | impl std::fmt::Display for Environment { |
| 8 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 9 | write!(f, "{}", self.to_str()) |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | impl std::str::FromStr for Environment { |
| 14 | type Err = (); |
| 15 | |
| 16 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 17 | match s.to_lowercase().as_str() { |
| 18 | "dev" => Ok(Environment::Dev), |
| 19 | "production" => Ok(Environment::Production), |
| 20 | _ => Err(()), |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | impl Environment { |
| 26 | pub fn to_str(&self) -> &str { |
| 27 | match self { |
| 28 | Environment::Dev => "dev", |
| 29 | Environment::Production => "production", |
| 30 | } |
| 31 | } |
| 32 | pub fn smb_dir(&self) -> String { |
| 33 | match self { |
| 34 | Environment::Dev => ".smb-dev".to_string(), |
| 35 | Environment::Production => ".smb".to_string(), |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | pub fn api_protocol(&self) -> String { |
| 40 | match self { |
| 41 | Environment::Dev => "http".to_string(), |
| 42 | Environment::Production => "https".to_string(), |
| 43 | } |
| 44 | } |
| 45 | pub fn api_host(&self) -> String { |
| 46 | match self { |
| 47 | Environment::Dev => "localhost:8088".to_string(), |
| 48 | Environment::Production => "api.smbcloud.xyz".to_string(), |
| 49 | } |
| 50 | } |
| 51 | } |