From c41c0d46fd469696c0f417b4b53ed813c3cfb685 Mon Sep 17 00:00:00 2001 From: Sander Date: Sun, 16 Feb 2025 15:47:07 +0400 Subject: [PATCH] devenv: add tos step to remaining generate feature --- devenv/src/cli.rs | 8 +++++--- devenv/src/devenv.rs | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/devenv/src/cli.rs b/devenv/src/cli.rs index f8259898b..f9c1bd9ce 100644 --- a/devenv/src/cli.rs +++ b/devenv/src/cli.rs @@ -186,11 +186,13 @@ pub enum Commands { Init { target: Option }, #[command( - about = "Generate devenv.yaml and devenv.nix using AI", + about = "Generate devenv.yaml and devenv.nix from a prompt using AI", long_about = indoc! {" - Generate devenv.yaml and devenv.nix using AI. + Generate devenv.yaml and devenv.nix from a prompt using AI. - Use of this feature is subject to the terms of service at https://devenv.new/tos + Use of this feature is subject to: + - Terms of Service: https://devenv.new/tos + - Privacy Policy: https://devenv.new/privacy "} )] Generate { diff --git a/devenv/src/devenv.rs b/devenv/src/devenv.rs index a6b5d6ce5..c2224342d 100644 --- a/devenv/src/devenv.rs +++ b/devenv/src/devenv.rs @@ -207,6 +207,29 @@ impl Devenv { host: &str, disable_telemetry: bool, ) -> Result<()> { + let accept_tos = self.devenv_dotfile.join("devenv-new-accept-tos"); + if !accept_tos.exists() { + let confirm = dialoguer::Confirm::new() + .with_prompt(indoc::formatdoc! {" + Before using 'devenv generate', please review and accept our Terms of Service and Privacy Policy: + + 1. Terms of Service: https://devenv.new/tos + 2. Privacy Policy: https://devenv.new/privacy + + They govern your use of our service and explain how we handle your data. + + By proceeding, you acknowledge that you have read and agree to these terms. + + Do you accept the Terms of Service and Privacy Policy? + "}) + .interact() + .into_diagnostic()?; + if !confirm { + bail!("You must agree to the Terms of Service and Privacy Policy to use this feature."); + } + fs::write(accept_tos, "").into_diagnostic()?; + } + let client = reqwest::Client::new(); let request = client .post(host)