Skip to content

Commit

Permalink
feat: Remove compile time environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kdheepak committed Feb 18, 2024
1 parent a07c252 commit af6650f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions code/crates-tui-tutorial-app/src/crates_io_api_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crates_io_api::CratesQuery;
use tokio::sync::mpsc::UnboundedSender;

use crate::action::Action;
use color_eyre::Result;
use color_eyre::{eyre::Context, Result};

// ANCHOR: search_parameters
/// Represents the parameters needed for fetching crates asynchronously.
Expand Down Expand Up @@ -42,7 +42,7 @@ pub async fn request_search_results(
/// into a result pattern.
fn create_client() -> Result<crates_io_api::AsyncClient, String> {
// ANCHOR: client
let email = env!("CRATES_TUI_TUTORIAL_APP_MYEMAIL");
let email = std::env::var("CRATES_TUI_TUTORIAL_APP_MYEMAIL").context("Need to set CRATES_TUI_TUTORIAL_APP_MYEMAIL environment variable to proceed").unwrap();

let user_agent = format!("crates-tui ({email})");
let rate_limit = std::time::Duration::from_millis(1000);
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/tutorials/crates-tui/crates-io-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This `AsyncClient` can be initialized as follows:

In order to initialize the client, we have to provide an email as the user agent. In the source code
of this tutorial, we read an email from the environment variable `CRATES_TUI_TUTORIAL_APP_MYEMAIL`
at compile time.
at run time.

:::tip

Expand Down

0 comments on commit af6650f

Please sign in to comment.