View | Details | Raw Unified | Return to bug 264301
Collapse All | Expand All

(-)b/sysutils/as-tree/Makefile (+37 lines)
Added Link Here
1
PORTNAME=	as-tree
2
DISTVERSION=	0.12.1
3
CATEGORIES=	sysutils
4
5
MAINTAINER=	sec.research.2005@gmail.com
6
COMMENT=	Print a list of paths as a tree of paths
7
8
LICENSE=	BlueOak
9
LICENSE_NAME=	Blue Oak Model License
10
LICENSE_FILE=	${WRKSRC}/LICENSE.md
11
LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
12
13
USES=		cargo
14
USE_GITHUB=	yes
15
GH_ACCOUNT=	jez
16
GH_TAGNAME=	0036c20
17
18
OPTIONS_DEFINE=		DOCS
19
OPTIONS_DEFAULT=	DOCS
20
21
PORTDOCS=	README.md
22
23
CARGO_CRATES=	ansi_term-0.12.1 \
24
		atty-0.2.14 \
25
		hermit-abi-0.1.12 \
26
		libc-0.2.70 \
27
		lscolors-0.7.0 \
28
		winapi-0.3.8 \
29
		winapi-i686-pc-windows-gnu-0.4.0 \
30
		winapi-x86_64-pc-windows-gnu-0.4.0
31
32
PLIST_FILES=	bin/${PORTNAME}
33
34
post-install:
35
	${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/${PORTNAME}
36
37
.include <bsd.port.mk>
(-)b/sysutils/as-tree/distinfo (+19 lines)
Added Link Here
1
TIMESTAMP = 1652470669
2
SHA256 (rust/crates/ansi_term-0.12.1.crate) = d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2
3
SIZE (rust/crates/ansi_term-0.12.1.crate) = 24838
4
SHA256 (rust/crates/atty-0.2.14.crate) = d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8
5
SIZE (rust/crates/atty-0.2.14.crate) = 5470
6
SHA256 (rust/crates/hermit-abi-0.1.12.crate) = 61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4
7
SIZE (rust/crates/hermit-abi-0.1.12.crate) = 9217
8
SHA256 (rust/crates/libc-0.2.70.crate) = 3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f
9
SIZE (rust/crates/libc-0.2.70.crate) = 472909
10
SHA256 (rust/crates/lscolors-0.7.0.crate) = 1f77452267149eac960ded529fe5f5460ddf792845a1d71b5d0cfcee5642e47e
11
SIZE (rust/crates/lscolors-0.7.0.crate) = 18036
12
SHA256 (rust/crates/winapi-0.3.8.crate) = 8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6
13
SIZE (rust/crates/winapi-0.3.8.crate) = 1128308
14
SHA256 (rust/crates/winapi-i686-pc-windows-gnu-0.4.0.crate) = ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6
15
SIZE (rust/crates/winapi-i686-pc-windows-gnu-0.4.0.crate) = 2918815
16
SHA256 (rust/crates/winapi-x86_64-pc-windows-gnu-0.4.0.crate) = 712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f
17
SIZE (rust/crates/winapi-x86_64-pc-windows-gnu-0.4.0.crate) = 2947998
18
SHA256 (jez-as-tree-0.12.1-0036c20_GH0.tar.gz) = e598fe12f95f464a7768a7f7317ab7af2741c97a6867297d52b210b34012a25b
19
SIZE (jez-as-tree-0.12.1-0036c20_GH0.tar.gz) = 132668
(-)b/sysutils/as-tree/files/patch-src__main.rs (+107 lines)
Added Link Here
1
--- src/main.rs.orig	2021-03-09 04:30:36 UTC
2
+++ src/main.rs
3
@@ -4,7 +4,7 @@
4
 
5
 use std::collections::BTreeMap;
6
 use std::fs::File;
7
-use std::io::{self, BufRead, BufReader};
8
+use std::io::{self, BufRead, BufReader, Write};
9
 use std::path::{Path, PathBuf};
10
 
11
 use lscolors::{LsColors, Style};
12
@@ -41,13 +41,14 @@
13
 
14
     fn _print(
15
         &self,
16
+        stdout: &mut io::StdoutLock,
17
         top: bool,
18
         prefix: &str,
19
         join_with_parent: bool,
20
         lscolors: &LsColors,
21
         parent_path: PathBuf,
22
         full_path: bool,
23
-    ) {
24
+    ) -> io::Result<()> {
25
         let normal_prefix = format!("{}│   ", prefix);
26
         let last_prefix = format!("{}    ", prefix);
27
 
28
@@ -84,48 +85,54 @@
29
                     "/"
30
                 };
31
                 if should_print {
32
-                    print!("{}{}{}", style.paint(joiner), painted, newline);
33
+                    write!(stdout, "{}{}{}", style.paint(joiner), painted, newline)?;
34
                 }
35
                 prefix
36
             } else if !is_last {
37
                 if should_print {
38
-                    print!("{}├── {}{}", prefix, painted, newline);
39
+                    write!(stdout, "{}├── {}{}", prefix, painted, newline)?;
40
                 }
41
                 &normal_prefix
42
             } else {
43
                 if should_print {
44
-                    print!("{}└── {}{}", prefix, painted, newline);
45
+                    write!(stdout, "{}└── {}{}", prefix, painted, newline)?;
46
                 }
47
                 &last_prefix
48
             };
49
 
50
             it._print(
51
+                stdout,
52
                 false,
53
                 next_prefix,
54
                 contains_singleton_dir,
55
                 lscolors,
56
                 current_path,
57
                 full_path,
58
-            )
59
+            )?;
60
         }
61
+
62
+        Ok(())
63
     }
64
 
65
-    fn print(&self, lscolors: &LsColors, full_path: bool) {
66
+    fn print(&self, lscolors: &LsColors, full_path: bool) -> io::Result<()> {
67
         if self.trie.is_empty() {
68
-            println!();
69
-            return;
70
+            return Ok(());
71
         }
72
 
73
+        let stdout = io::stdout();
74
+        let handle = &mut stdout.lock();
75
+
76
         // This works because PathBuf::from(".").join(PathBuf::from("/")) == PathBuf::from("/")
77
         let current_path = PathBuf::from(".");
78
         let contains_singleton_dir = self.contains_singleton_dir();
79
 
80
         if !contains_singleton_dir {
81
             let style = ansi_style_for_path(&lscolors, &current_path);
82
-            println!("{}", style.paint(current_path.to_string_lossy()));
83
+            writeln!(handle, "{}", style.paint(current_path.to_string_lossy()))?;
84
         }
85
 
86
         self._print(
87
+            handle,
88
             true,
89
             "",
90
             contains_singleton_dir,
91
@@ -175,7 +182,14 @@
92
         options::Colorize::Never => LsColors::empty(),
93
     };
94
 
95
-    trie.print(&lscolors, options.full_path);
96
+    let result = trie.print(&lscolors, options.full_path);
97
 
98
-    io::Result::Ok(())
99
+    match result {
100
+        Err(e) if e.kind() == io::ErrorKind::BrokenPipe => {
101
+            // ignore broken pipe errors
102
+            io::Result::Ok(())
103
+        },
104
+        e@Err(_) => e,
105
+        _ => io::Result::Ok(())
106
+    }
107
 }
(-)b/sysutils/as-tree/pkg-descr (-1 / +9 lines)
Added Link Here
0
- 
1
Print a list of paths as a tree of paths
2
3
This tool is particularly useful when used with `find` or `fd`
4
to produce such a list of files.
5
It's similar in spirit to `tree`, but `find` and `fd` tend to be
6
more powerful when it comes to controlling which files to list.
7
8
9
WWW: https://github.com/ez/as-tree

Return to bug 264301