Skip to content

Commit

Permalink
Added documentation for config options to README.
Browse files Browse the repository at this point in the history
  • Loading branch information
RRArny committed Oct 17, 2024
1 parent 9f1271e commit 51725ea
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
45 changes: 38 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,45 @@ If there is any problem with the provided arguments WXfetch will print an error

## Configuration

So far, no configuration options other than the ones described above are recognised, but they're coming in the future!
The configuration is loaded from `~/.config/wxfetch/config.toml` or from a TOML-file as specified by the `-c` flag.

## Providing API keys
Except for position, these options present personal minima and reflect the colours used. For instance a cloud layer with an altitude lower than the specified minimum will be rendered red.

It is advisable to just copy and modify the sample file from the git repository. The program expects the file to be structured as follows:

### Position

- `airfield`: ICAO or IATA code of the reporting aerodrome.
- `lat` & `lon`: Latitude and longitude. The program will look for the nearest reporting station to these coordinates.

If none of the options above are supplies the program defaults to geoip. Positions supplied as command line parameters override the options from the config file.

### Clouds

For wxfetch to work you will need a free account on https://avwx.rest/. Once you have created an account, go ahead and copy `secrets_template.toml` to `secrets.toml` and paste in your API key.
- `cloud_minimum`: Minimum altitude for cloud layers.
- `cloud_marginal`: Altitude at which cloud layers will still be considered marginal.

### Temperature

## Todos
- `temp_minimum`: Minimum temperature.
- `spread_minimum`: Minimum spread.

### Wind

- `wind_var_maximum`: Maximum wind variability.
- `wind_maximum`: Maximum wind speed.
- `gust_maximum`: Maximum gust difference.

### Age

- `age_maximum`: Maximum age of the report.
- `age_marginal`: Marginal age of the report.

### Visibility

- `visibility_minimum`: Minimum visibility.
- `visibility_marginal`: Marginal visibility.

## Providing API keys

- [ ] Configuration options
- [ ] Personal wx minima
- [ ] Load secret from environment instead of file
For wxfetch to work you will need a free account on https://avwx.rest/. Once you have created an account, go ahead and set the environment variable `AVWX_API_KEY` to your API key.
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ fn read_config_file(config_filepath: Option<String>) -> Config {
let mut config = Config::default();
let config_filepath = config_filepath
.unwrap_or(std::env::var("HOME").expect(msg) + "/.config/wxfetch/config.toml");
let mut config_file = File::open(config_filepath).expect(msg);
let config_file = File::open(config_filepath.clone());
if config_file.is_err() {
println!("Could not open config file at {config_filepath}. Proceeding with defaults...");
return config;
}
let mut config_file = config_file.unwrap();
let mut contents = String::new();
config_file.read_to_string(&mut contents).expect(msg);
let contents = contents.parse::<Table>().expect(msg);
Expand Down

0 comments on commit 51725ea

Please sign in to comment.