Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split unit systems per type #195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nikonhub
Copy link

@nikonhub nikonhub commented Oct 3, 2024

Temperature, Speed & Distance

Motivation and Context

Allow to configure temperature, speed and distance unit separately.
It opens more possibilities for more units if needed
Also add beaufort unit for wind speed btw.

Partially answers #126

Description

Remove of a single "unit" config variable and replace with "unit-distance", "unit-speed", "unit-temperature".

Steps for Testing

  1. change a unit in .wegorc unit-speed=beaufort
  2. run wego

Screenshots

image

Temperature, Speed & Distance
// half the distance between sunrise and sunset
noon_distance := time.Duration(int64(float32(astro.Sunset.UnixNano()-astro.Sunrise.UnixNano()) * 0.5))
// time for solar noon
noon := astro.Sunrise.Add(noon_distance)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem like non standard indents. Please don't reformat code in PRs unless you are changing the line. This makes the diff harder to read.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I know, not the best practice. Sorry. But go extensions just format the whole file. I will remove it

@@ -46,12 +46,13 @@ func main() {
flag.StringVar(location, "l", "40.748,-73.985", "`LOCATION` to be queried (shorthand)")
numdays := flag.Int("days", 3, "`NUMBER` of days of weather forecast to be displayed")
flag.IntVar(numdays, "d", 3, "`NUMBER` of days of weather forecast to be displayed (shorthand)")
unitSystem := flag.String("units", "metric", "`UNITSYSTEM` to use for output.\n \tChoices are: metric, imperial, si, metric-ms")
flag.StringVar(unitSystem, "u", "metric", "`UNITSYSTEM` to use for output. (shorthand)\n \tChoices are: metric, imperial, si, metric-ms")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the idea here for migrating older wegorc's to the new settings? I still think we should keep the compatibility with setting a single unit for all three instead of just having the per-type unit. At least in the settings file it still makes sense, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to keep it initially for backward compatibility. But then thought "what for", it seems less clear to have all four options at the same time.

Also we have to decide which takes precedence over which one:

  • Global unit overrides individual units : Great backward compatibility and not disrupt existing users configuration. But it means we would have to allow an empty string as global unit to allow per unit configuration.

  • Individual units override global unit : Standard way. But ingo would create the new units with default values in the configuration file. And the existing global unit wouldn't be used anyway. Or we rather allow empty values for individual units as default.

What do you think, how should we proceed then?

@kordianbruck
Copy link
Collaborator

Partially answers #126

How would this help here? If you'd like to reference that issue, please make sure to at least have the new flags accept multiple units as values. (even if you don't implement that feature fully in this PR)

@nikonhub
Copy link
Author

nikonhub commented Oct 7, 2024

It allows to customize each unit individually. I've added Beaufort scale to speed unit. Which would not be possible otherwise.
It's an open ground to further customize each unit, with multiple units for example.
I can work on it but it also changes the UI. I'm not sure how to fit multiple number in a single card
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants