Mercurial > core / rust/bin/alik/main.rs
changeset 698: |
96958d3eb5b0 |
parent: |
94d358919982
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
1 //! app/cli/alik/main.rs --- Alik 6 use clap::{Parser, Subcommand}; 7 use logger::{debug, error, trace, warn, Logger}; 8 use std::path::PathBuf; 9 use util::{cli::log_level_str_from_cli, Result}; 10 #[derive(Debug, Parser)] 11 #[command(name="alik",author, version, about, long_about = None)] 14 #[command(subcommand)] 16 /// Set the default config file 17 #[arg(short, long, env = "ALIK_CONFIG_FILE")] 20 #[arg(short, long, action = clap::ArgAction::Count)] 24 #[derive(Debug, Subcommand)] 26 /// start the Alik service 27 Start { service: Option<String> }, 33 /// Ping remote services 38 async fn main() -> Result<()> { 40 let args = Cli::parse(); 42 Logger::try_with_str(log_level_str_from_cli(args.level))?.start()?; 45 let cfg = if let Some(path) = args.cfg { 46 match AlikConfig::load(path.clone()) { 50 warn!("{path:?}: {e}, using default config"); 58 let alik = Alik::with_config(&cfg); 62 if let Some(cmd) = args.cmd { 64 Cmd::Start { service: srv } => { 65 // start_service().await; 66 if let Some(s) = srv { 69 graphql::start_graphiql("127.0.0.1:0").await; 73 start_http_proxy("127.0.0.1:0").await; 77 error!("invalid service name"); 83 tokio::spawn(async move { start_http_proxy("127.0.0.1:0").await }); 84 let graphiql = tokio::spawn(async move { 85 graphql::start_graphiql("127.0.0.1:0").await 88 tokio::try_join!(graphiql, http_proxy)?; 92 Cmd::Ping {} => Ok(()), 93 Cmd::Show { kind: _ } => Ok(()),