Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ folders 4
- Arguments are split the way a shell would, so quotes work:
`/cmd lumen search "harbour at dawn"`.
- stdout and stderr are both captured, capped at `max_results` rows; a single
line longer than 500 characters is truncated.
line longer than 500 characters is truncated and says how many characters
were dropped (`… (+39412 chars)`).
- The exit code is shown on the summary line.
- **It gives up after five seconds.** A launcher that freezes is worse than one
that says "still running", so a command that outlives the cap is reported and
Expand Down Expand Up @@ -84,7 +85,7 @@ desktop shortcut or global hotkey; it stays resident in the background and
| 🪟 **Tray-resident, one keystroke** | Lives in the background; the shortcut **summons** the existing window instead of opening a duplicate |
| 🧠 **Smart routing cascade** | math → unit conversion → existing path → PATH binary → web search |
| 🧮 **Zero-dep calculator** | `+ - * / % ^ ( )` with unary minus, right-associative power, div/mod-by-zero guards |
| 📐 **Unit conversion** | `10 km in mi`, `100 f to c`, `5kg to lb` — length, mass, temperature |
| 📐 **Unit conversion** | `10 km in mi`, `2 h in min`, `10 GB in MB` — ten dimensions: length, mass, time, volume, area, speed, data, pressure, energy, temperature |
| 🗂️ **Slash commands** | `/run` `/cmd` `/open` `/ls` `/find` `/web` `/calc` `/sys` `/help` `/clear` |
| ⏱️ **Command history** | `↑`/`↓` (or `Ctrl+P`/`Ctrl+N`), persisted between runs |
| 📋 **Copy without a clipboard crate** | `Ctrl+Y` copies the last result via OSC 52 — works over SSH |
Expand Down
5 changes: 5 additions & 0 deletions changes/cmd-truncation-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
bump: patch
---

A `/cmd` output line cut at 500 characters now says how many characters were dropped, so a truncated line reads as truncated instead of as a wrapped one.
5 changes: 5 additions & 0 deletions changes/units-ten-dimensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
bump: minor
---

Unit conversion covers ten dimensions: time, volume, area, speed, data, pressure and energy join length, mass and temperature. `10 in in cm`, `1e3 m in km` and `2*3 km in mi` now parse instead of falling through to a web search.
22 changes: 19 additions & 3 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,25 @@ on PATH as a binary? → spawn detached e.g. code .
otherwise? → web search e.g. rust lifetimes
```

Unit conversion understands length (`mm cm m km in ft yd mi nmi`), mass
(`mg g kg oz lb st t`) and temperature (`c f k`), and accepts long names
(`10 kilometres in miles`).
Unit conversion understands ten dimensions:

| Dimension | Units |
|---|---|
| length | `mm cm m km in ft yd mi nmi` |
| mass | `mg g kg oz lb st t` |
| time | `ms s min h day week` |
| volume | `ml cl dl l m3 tsp tbsp floz cup pint quart gal` |
| area | `m2 km2 cm2 ha acre ft2 yd2 mi2` |
| speed | `m/s km/h mph kn ft/s` |
| data | `b kb mb gb tb` (decimal, 1 kB = 1000 B) and `kib mib gib tib` (binary) |
| pressure | `pa kpa mpa bar mbar atm psi mmhg torr` |
| energy | `j kj mj cal kcal wh kwh btu` |
| temperature | `c f k` |

Long names work (`10 kilometres in miles`, `2 hours in minutes`). The amount on
the left may be a literal, an exponent (`1e3 m in km`) or an expression
(`2*3 km in mi`). A unit only converts inside its own dimension: `10 km in kg`
is not a conversion, and falls through to the next step of the cascade.

## 4. Slash commands

Expand Down
9 changes: 5 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ <h3>Zero-dep calculator</h3>
<span class="tag">04</span>
<svg class="ico" aria-hidden="true"><use href="#i-ruler"/></svg>
<h3>Unit conversion</h3>
<p><code>10 km in mi</code>, <code>100 f to c</code>, <code>5kg to lb</code> — length, mass and temperature.</p>
<p><code>10 km in mi</code>, <code>2 h in min</code>, <code>10 GB in MB</code> — ten dimensions, from length and mass to time, data, pressure and energy.</p>
</article>
<article class="card reveal">
<span class="tag">05</span>
Expand Down Expand Up @@ -568,9 +568,10 @@ <h3 class="reveal" style="margin-top:2.4rem;font-family:var(--mono);color:var(--
<span class="node">PATH binary</span><span class="arw">→</span>
<span class="node hot">web search</span>
</div>
<p class="note" style="max-width:52rem">Unit conversion understands length (<code>mm cm m km in ft yd mi nmi</code>),
mass (<code>mg g kg oz lb st t</code>) and temperature (<code>c f k</code>), and accepts long names such as
<code>10 kilometres in miles</code>.</p>
<p class="note" style="max-width:52rem">Unit conversion understands ten dimensions — length, mass, time, volume,
area, speed, data, pressure, energy and temperature — accepts long names such as
<code>10 kilometres in miles</code>, and reads exponents and expressions on the amount
(<code>1e3 m in km</code>, <code>2*3 km in mi</code>).</p>
</div>
</section>

Expand Down
20 changes: 18 additions & 2 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,18 @@ fn split_args(raw: &str) -> Result<Vec<String>, String> {
Ok(out)
}

/// Cut a long output line at `cap` characters and say how much was dropped.
///
/// A bare ellipsis leaves the reader unable to tell a line that just wrapped
/// from one with 40 KB of minified JSON behind it; the count makes the size of
/// what is missing visible without printing any of it.
fn truncate_line(line: &str, cap: usize) -> String {
if line.chars().count() <= cap {
let total = line.chars().count();
if total <= cap {
return line.to_string();
}
let mut s: String = line.chars().take(cap).collect();
s.push('…');
s.push_str(&format!("… (+{} chars)", total - cap));
s
}

Expand Down Expand Up @@ -924,4 +930,14 @@ mod tests {
fn url_encoding() {
assert_eq!(urlencode("hi there&you"), "hi+there%26you");
}

#[test]
fn long_lines_say_how_much_was_cut() {
let line = "x".repeat(600);
let out = truncate_line(&line, 500);
assert!(out.ends_with("… (+100 chars)"), "truncation marker missing");
assert_eq!(out.chars().count(), 500 + "… (+100 chars)".chars().count());
// A line at or under the cap is untouched.
assert_eq!(truncate_line("short", 500), "short");
}
}
Loading
Loading