Skip to content

Commit

Permalink
weather cli from Chris Biscardi
Browse files Browse the repository at this point in the history
  • Loading branch information
bragasgambit committed Jul 30, 2024
1 parent 44fbb23 commit cefe3c6
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*.pdf
*.png
rust/target/
docker/
2 changes: 2 additions & 0 deletions rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
*.lock
7 changes: 0 additions & 7 deletions rust/Cargo.lock

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions rust/hello_world/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
println!("Hello, World!");
println!("I'm a Rustacean!");
}
19 changes: 19 additions & 0 deletions rust/initialize_project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Install https://rustup.rs/
Install https://crates.io/crates/cargo-edit/

Creating a new project:
$ cargo new <dir_name>

This will create a Cargo.toml (similar to package.json for JS projects) and a src/main.rs
If not specified, cargo will assume that the project is a binary. By convention, src/main.rs is a entrypoint for a binary (just like index.js for JS projects)


To run a binary:
project_root$ cargo run

To compile:
$ rustc <file_name.rs>

To execute:
$ ./file_name

9 changes: 0 additions & 9 deletions rust/src/main.rs

This file was deleted.

8 changes: 8 additions & 0 deletions rust/weather-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "weather-cli"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
12 changes: 12 additions & 0 deletions rust/weather-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fn main() {
let api_token: String = std::env::var("API_TOKEN")
.expect("expected there to be an api token");

dbg! (api_token);


// enum Result<THING_WE_WANT, ERROR_THAT_COULD_HAPPEN> {
// Ok(THING_WE_WANT),
// Err(ERROR_THAT_COULD_HAPPEN)
// }
}

0 comments on commit cefe3c6

Please sign in to comment.