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

Lazy syntax for boring components #17

Open
Wilm0r opened this issue Oct 8, 2024 · 0 comments
Open

Lazy syntax for boring components #17

Wilm0r opened this issue Oct 8, 2024 · 0 comments

Comments

@Wilm0r
Copy link

Wilm0r commented Oct 8, 2024

I like strava-gear! Takes some guesswork out of how much distance I get out of my chains etc. :) But writing the rule file feels a little repetitive especially for boring components like chains.

I've patched up process_rule() a little bit with this:

            for kind, name in v.items():
                if name.startswith("-"):
                    suffix = name[1:].strip("-")
                    if suffix:
                        v[kind] = "%s-%s-%s" % (k, kind, suffix)
                    elif "since" in kwargs:
                        v[kind] = "%s-%s-%s" % (k, kind, kwargs["since"].strftime("%Y%m"))
                    else:
                        v[kind] = "%s-%s-%s" % (k, kind, "000000")

So now I can just type role: -- and it'll name the part $BIKE-$ROLE-$YEAR$MONTH. Or role: -gp4k-2014 and it'll add the $BIKE-$ROLE prefix only, so I can at least track mildly interesting info like what model tyre I've installed that time. (And $BIKE-$ROLE-000000 for the stock-installed parts. -stock is nicer but doesn't sort as nicely.)

Am I the only one who likes this shorthand kind of syntax or is this worth a cleaned up PR?

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

No branches or pull requests

1 participant