Crates.io | darkness-check |
lib.rs | darkness-check |
version | 0.1.0 |
source | src |
created_at | 2022-09-18 15:44:41.483089 |
updated_at | 2022-09-18 15:44:41.483089 |
description | Find out how many hours of darkness you are in for today. |
homepage | |
repository | https://github.com/sarahghp/darkness |
max_upload_size | |
id | 668664 |
size | 894,484 |
A little CLI, built in Rust that lets you find out how many hours of darkness you're in for today.
There are a handful of ways to use the darkness-check
app, balanced between looking up lat-long for locations yourself or getting an API key so the app can look it up for you.
darkness-check <LAT> <LONG>
NOTE: If you have provided an API key, this will fail and you should look up by city and country OR you can overwrite it by using the env variable
DARK_POINT="52.520008 13.404954" darkness-check
Put the latitude and longitude points in your dark-config.toml
or dark-config.json
.
# dark-config.toml
point = "52.520008 13.404954"
Then call it like this:
darkness-check
The dark-config
file must be in the same directory hierarchy as the executable. (That is, it can be in parent directory, etc.)
If you want to look up locations by name, you will need to create a free account at API Ninjas and add the key
field to dark-config.toml
.
# dark-config.toml
key = "API_KEY_FROM_API_NINJAS"
Then look up any city and country.
darkness-check berlin germany
Put cities with multiple words in quotes.
darkness-check "mexico city" mexico
The dark-config
file must be in the same directory hierarchy as the executable, but if you don't like that, the API key can also be provided as an environment variable.
DARK_KEY="jfhkaljkrhfjrhuljkhs" darkness-check berlin germany
[ ] Add multiple points in the config. [ ] Put the config file in a better place.
There are two ways to install the tool: manually or using cargo install
. If you already use Rust, the latter is almost certainly easier. If you don't yet, but want to install it on your system, start here. And if don't want to install it on your system or are a control freak like me, you may find the manual install more to your liking.
Download the latest release; decompress and add to your path.
Decompress either by double-clicking the dwnloaded file or with
tar –xvf {downloaded-file-name}.tar.gz
Then, add the file to your PATH
. One way to do this is to create a folder for your command line apps and add this whole folder to your PATH
:
cd ~ # move to your home folder
mkdir bin # create a directory called bin
cd <UNCOMPRESSED_DARKNESS_DIRECTORY> # on a mac, to get this path you can drag the folder from finder into the command line
cp darkness-check ~/bin # move it to the directory we created
echo "export PATH=$HOME/bin:$PATH" >> ~/.zshrc # replace ~/.zshrc with ~/.bashrc
If the last line fails and tells you you do not have a ~/.zshrc
or ~/.bashrc
, you can create one using the touch
command:
touch ~/.bashrc
You can check that installation was successful by opening a new terminal window and typing:
which darkness-check
Now you can run darkness-check
. Well, almost, if you're on a Mac. This is an unsigned app, so after you try to run it for the first time, you will get an error say it's unsigned. Go to Security & Privacy > General
, and click Allow anyway
.
If you want to use a config file, I recommend adding it to ~
: touch dark-config.toml
.
Windows users will also want to add the executable to their $PATH
. Since I don't have a Windows machine, I have not tested it, but this tutorial and this video show the steps.
If you run into issues or can provide more information, please feel free to open an issue or PR.
Built as an @axodotdev onboarding project.