CLI dispatch holds many futures; OK at top level.
()
| 1938 | #[tokio::main] |
| 1939 | #[allow(clippy::large_stack_frames)] // CLI dispatch holds many futures; OK at top level. |
| 1940 | async fn main() -> Result<()> { |
| 1941 | // Install the rustls crypto provider before completion runs — completers may |
| 1942 | // establish TLS connections to the gateway. |
| 1943 | rustls::crypto::ring::default_provider() |
| 1944 | .install_default() |
| 1945 | .map_err(|e| miette::miette!("failed to install rustls crypto provider: {e:?}"))?; |
| 1946 | |
| 1947 | CompleteEnv::with_factory(Cli::command).complete(); |
| 1948 | |
| 1949 | let cli = Cli::parse(); |
| 1950 | let mut tls = TlsOptions::default(); |
| 1951 | tls.gateway_insecure = cli.gateway_insecure; |
| 1952 | |
| 1953 | // Set up logging based on verbosity |
| 1954 | let log_level = match cli.verbose { |
| 1955 | 0 => "warn", |
| 1956 | 1 => "info", |
| 1957 | 2 => "debug", |
| 1958 | _ => "trace", |
| 1959 | }; |
| 1960 | |
| 1961 | tracing_subscriber::fmt() |
| 1962 | .with_env_filter( |
| 1963 | tracing_subscriber::EnvFilter::try_from_default_env() |
| 1964 | .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(log_level)), |
| 1965 | ) |
| 1966 | .init(); |
| 1967 | |
| 1968 | // Propagate verbosity to the OpenSSH LogLevel used by SSH subprocesses. |
| 1969 | // Only set the env var when it hasn't been explicitly overridden by the |
| 1970 | // user, so `OPENSHELL_SSH_LOG_LEVEL=DEBUG openshell ...` still wins. |
| 1971 | if std::env::var("OPENSHELL_SSH_LOG_LEVEL").is_err() { |
| 1972 | let ssh_log_level = match cli.verbose { |
| 1973 | 0 => "ERROR", |
| 1974 | 1 => "INFO", |
| 1975 | _ => "DEBUG", |
| 1976 | }; |
| 1977 | // SAFETY: Called early in main() before spawning async tasks that |
| 1978 | // read the environment, so no concurrent readers exist. |
| 1979 | #[allow(unsafe_code)] |
| 1980 | unsafe { |
| 1981 | std::env::set_var("OPENSHELL_SSH_LOG_LEVEL", ssh_log_level); |
| 1982 | } |
| 1983 | } |
| 1984 | |
| 1985 | match cli.command { |
| 1986 | // ----------------------------------------------------------- |
| 1987 | // Gateway commands (was `cluster` / `cluster admin`) |
| 1988 | // ----------------------------------------------------------- |
| 1989 | Some(Commands::Gateway { |
| 1990 | command: Some(command), |
| 1991 | }) => match command { |
| 1992 | GatewayCommands::Add { |
| 1993 | endpoint, |
| 1994 | name, |
| 1995 | remote, |
| 1996 | local, |
| 1997 | oidc_issuer, |
nothing calls this directly
no test coverage detected