1use std::process::Command;
3pub fn retrieve_less_version() -> Option<usize> {
4 let cmd = Command::new("less").arg("--version").output().ok()?;
5 parse_less_version(&cmd.stdout)
8fn parse_less_version(output: &[u8]) -> Option<usize> {
9 if output.starts_with(b"less ") {
10 let version = std::str::from_utf8(&output[5..]).ok()?;
11 let end = version.find(' ')?;
12 version[..end].parse::<usize>().ok()
19fn test_parse_less_version_487() {
20 let output = b"less 487 (GNU regular expressions)
21Copyright (C) 1984-2016 Mark Nudelman
23less comes with NO WARRANTY, to the extent permitted by law.
24For information about the terms of redistribution,
25see the file named README in the less distribution.
26Homepage: http://www.greenwoodsoftware.com/less";
28 assert_eq!(Some(487), parse_less_version(output));
32fn test_parse_less_version_551() {
33 let output = b"less 551 (PCRE regular expressions)
34Copyright (C) 1984-2019 Mark Nudelman
36less comes with NO WARRANTY, to the extent permitted by law.
37For information about the terms of redistribution,
38see the file named README in the less distribution.
39Home page: http://www.greenwoodsoftware.com/less";
41 assert_eq!(Some(551), parse_less_version(output));
45fn test_parse_less_version_wrong_program() {
46 let output = b"more from util-linux 2.34";
48 assert_eq!(None, parse_less_version(output));
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list