#converter #temperature #cli

app tempr

A fast, command-line fahrenheit to celcius converter

5 stable releases

1.2.0 May 19, 2024
1.1.3 May 15, 2024
1.1.1 May 14, 2024

#1 in #temperature

Download history 239/week @ 2024-05-12 160/week @ 2024-05-19

399 downloads per month

GPL-3.0-or-later

21KB
65 lines

builds.sr.ht status License: GPL v3

tempr

Version 1.2.0

Frequently Unasked Questions

Is this the program I'm looking for?

Probably not.

What does this program do?

It's a command-line program for UNIX-like systems that converts from Fahrenheit to Celsius and vice versa. So if you type:

$ tempr 23

It will give you:

23.0°F is -5.0°C
23.0°C is 73.4°F

You can also adjust the precision with the --precision switch, so that:

$ tempr --precision=3 -320.4

gives you:

-320.400°F is -195.778°C
-320.400°C is -544.720°F

The default precision is 1.

Doesn't GNU units already do this?

Yes.

So why did you write this thing?

Like many Americans, I am mostly illiterate when it comes to the metric system. It often happens, though, that I'm in a chatroom or something and one of my friends (who is living in some exotic locale like Ottawa) will say, "It's -4 degrees outside!" Which sounds insanely cold to me. But armed with tempr, I can say, "Cry me a river. That's not that cold."

How do I install this program?

This program is written in Rust, so you need a Rust compiler installed on your machine.

Assuming you have that taken care of, it'll be something like this:

$ cargo install tempr

Exactly where that installs the binary depends on your local configuration, but cargo is pretty clever, and can probably put it anywhere you like.

So let me get this straight. You wrote over sixty lines of code in Rust to do something this stupid?

Yes. I mostly use this project to play around with different languages, build tools, linters, and continuous integration systems before I recklessly incorporate them into larger projects.

And this particular problem is actually trickier than it looks, because when you type:

$ tempr -28

on the command line, UNIX-like systems assume that you must be trying to pass the tempr program some kind of weird option (maybe the -2 and -8 options smashed together?). Getting around that without exotic dependencies requires . . . hacking a solution (though for the record, I've never seen a system handle this more gracefully than Rust).

Oh, and tempr proved very useful when building nowa, which is a much more interesting and useful program.

Couldn't you have written this in, like, one line of Ruby/Python/JavaScript with no dependencies?

Probably.

Couldn't you have written an immaculately pure, provably correct version of this in Idris/Haskell/Coq?

Probably.

Shouldn't everything be written in Rust?

Probably not.

Why not do Kelvin?!

How long must I endure you people?

Yeah, it'd probably be cool. On the other hand, my friends were all humanities majors, so when they say, "It's 10 degrees!" they are definitely not talking about some substance being miraculously held at -263.15°C.

And why stop there? What about the Rankine scale? Or Isaac Newton's scale (devised in 1701) by which one may speak of the Calor aeris hyberni ubi aqua incipit gelu rigescere ("the heat of air in winter at which water begins to freeze"). My humanities friends are, after all, way better at Latin.

I don't know. Maybe version 2.

You sound like a jerk. Are you some kind of imperial-system zealot or something like that?

Nah, I think the metric system is way more rational, and it's the system used by most people the world over. I wish we (Americans, Libyans, Belizeans, and Myanmars) would switch. There's perhaps some hope for those last three, but the first seem curiously intractable on this point.

You don't sound like a lawyer. Does this thing have a license?

tempr is written and maintained by Stephen Ramsay (sramsay{at}protonmail{dot}com).

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Last Modified: 2024-05-19T15:53:32:-0500

Dependencies

~1.2–1.8MB
~34K SLoC