Skip to content

Commit

Permalink
devenv: add tos step to remaining generate feature
Browse files Browse the repository at this point in the history
  • Loading branch information
sandydoo committed Feb 16, 2025
1 parent becbbfe commit c41c0d4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
8 changes: 5 additions & 3 deletions devenv/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ pub enum Commands {
Init { target: Option<PathBuf> },

#[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 {
Expand Down
23 changes: 23 additions & 0 deletions devenv/src/devenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c41c0d4

Please sign in to comment.