xref: /freebsd/usr.bin/dpv/dpv.1 (revision 9268022b74279434ed6300244e3f977e56a8ceb5)
1.\" Copyright (c) 2013-2014 Devin Teske
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd Sep 7, 2014
28.Dt DPV 1
29.Os
30.Sh NAME
31.Nm dpv
32.Nd stream data from stdin or multiple paths with dialog progress view
33.Sh SYNOPSIS
34.Nm
35.Op options
36.Ar [bytes:]label
37.Nm
38.Op options
39.Fl m
40.Ar [bytes1:]label1
41.Ar path1
42.Op Ar [bytes2:]label2 path2 ...
43.Sh DESCRIPTION
44.Nm
45provides a dialog progress view, allowing a user to see current throughput rate
46and total data transferred for one or more streams.
47.Pp
48The
49.Nm
50utility has two main modes for processing input.
51.Pp
52The default input mode, without
53.Ql Fl m ,
54.Nm
55reads bytes from standard input.
56A label for the data must be provided.
57.Pp
58The secondary input mode, with
59.Ql Fl m ,
60.Nm
61reads multiple paths
62.Pq up to 2047 or Dq ARG_MAX/2-1 ,
63sequentially.
64.Pp
65Data read in either mode is either thrown away
66.Pq default ,
67sent to a spawned instance of the program specified via
68.Ql Fl x Ar cmd ,
69or sent to a unique file specified by
70.Ql Fl o Ar file .
71.Pp
72With or without
73.Ql Fl m ,
74progress is displayed using one of
75.Xr dialog 3
76.Pq default ,
77.Xr dialog 1
78.Pq see Ql Fl D ,
79or instead
80.Xr Xdialog 1
81.Pq see Ql Fl X .
82.Pp
83The following options are available:
84.Bl -tag -width ".Fl b Ar backtitle"
85.It Fl a Ar text
86Display
87.Ar text
88below the file progress indicator(s).
89.It Fl b Ar backtitle
90Display
91.Ar backtitle
92on the backdrop, at top-left, behind the dialog widget.
93When using
94.Xr Xdialog 1 ,
95this is displayed inside the window
96.Pq at the top
97followed by a separator line.
98.It Fl d
99Debug mode.
100Print dialog prompt data to standard out and provide additional debugging on
101standard error.
102.It Fl D
103Do not use the default interface of
104.Xr dialog 3 ,
105but instead spawn an instance of
106.Xr dialog 1 .
107The path to
108.Xr dialog 1
109is taken from the
110.Ev DIALOG
111environment variable or simply
112.Dq Li dialog
113if unset or NULL.
114.It Fl h
115Produce a short syntax usage with brief option descriptions and exit.
116Output is produced on standard error.
117.It Fl i Ar format
118Customize the single-file format string used to update the status line.
119Ignored when using either
120.Ql Fl D
121or
122.Ql Fl X
123which lack the ability to display the status line
124.Pq containing bytes/rate/thread information .
125Default value
126is
127.Dq Li %'10lli bytes read @ %'9.1f bytes/sec. .
128This format is used when handling one file.
129.It Fl I Ar format
130Customize the multi-file format string used to update the status line.
131Ignored when using either
132.Ql Fl D
133or
134.Ql Fl X
135which lack the ability to display the status line
136.Pq containing bytes/rate/thread information .
137Default value
138is
139.Dq Li %'10lli bytes read @ %'9.1f bytes/sec. [%i/%i busy/wait] .
140This format is used when handling more than one file.
141.It Fl l
142Line mode. Read lines from input instead of bytes.
143.It Fl L Ar size
144Label size.
145If negative, shrink to longest label width.
146.It Fl m
147Multi-input mode.
148Instead of reading bytes from standard input, read from a set of paths
149.Pq one for each label .
150By default, each path is processed sequentially in the order given.
151.It Fl n Ar num
152Display at-most
153.Ar num
154progress indicators per screen.
155If zero, display as many as possible.
156If negative, only display the main progress indicator.
157Default is 0.
158Maximum value is 10.
159.It Fl N
160No overrun.
161If enabled, stop reading known-length inputs when input reaches stated length.
162.It Fl o Ar file
163Output data to
164.Ar file .
165The first occurrence of
166.Ql %s
167.Pq if any
168in
169.Ql Ar file
170will be replaced with the
171.Ar label
172text.
173.It Fl p Ar text
174Display
175.Ar text
176above the file progress indicator(s).
177.It Fl P Ar size
178Mini-progressbar size.
179If negative, don't display mini-progressbars
180.Pq only the large overall progress indicator is shown .
181If zero, auto-adjust based on number of files to read.
182When zero and only one file to read, defaults to -1.
183When zero and more than one file to read, defaults to 17.
184.It Fl t Ar title
185Display
186.Ar title
187atop the dialog box.
188Note that if you use this option at the same time as
189.Ql Fl X
190and
191.Ql Fl b Ar backtitle ,
192the
193.Ar backtitle
194and
195.Ar title
196are effectively switched
197.Pq see BUGS section below .
198.It Fl T
199Test mode.
200Simulate reading a number of bytes, divided evenly across the number of files,
201while stepping through each percent value of each file to process.
202Appends
203.Dq Li [TEST MODE]
204to the status line
205.Pq to override, use Ql Fl u Ar format .
206No data is actually read.
207.It Fl U Ar num
208Update status line
209.Ar num
210times per-second.
211Default value is
212.Ql Li 2 .
213A value of
214.Ql Li 0
215disables status line updates.
216If negative, update the status line as fast as possible.
217Ignored when using either
218.Ql Fl D
219or
220.Ql Fl X
221which lack the ability to display the status line
222.Pq containing bytes/rate/thread information .
223.It Fl w
224Wide mode.
225Allows long
226.Ar text
227arguments used with
228.Ql Fl p
229and
230.Ql Fl a
231to bump the dialog width.
232Prompts wider than the maximum width will wrap
233.Pq unless using Xr Xdialog 1 ; see BUGS section below .
234.It Fl x Ar cmd
235Execute
236.Ar cmd
237.Pq via Xr sh 1
238and send it data that has been read.
239Data is available to
240.Ar cmd
241on standard input.
242With
243.Ql Fl m ,
244.Ar cmd
245is executed once for each
246.Ar path
247argument.
248The first occurrence of
249.Ql %s
250.Pq if any
251in
252.Ql Ar cmd
253will be replaced with the
254.Ar label
255text.
256.It Fl X
257Enable X11 mode by using
258.Xr Xdialog 1
259instead of
260.Xr dialog 1
261or
262.Xr dialog 3 .
263.El
264.Sh ENVIRONMENT
265The following environment variables are referenced by
266.Nm :
267.Bl -tag -width ".Ev USE_COLOR"
268.It Ev DIALOG
269Override command string used to launch
270.Xr dialog 1
271.Pq requires Ql Fl D
272or
273.Xr Xdialog 1
274.Pq requires Ql Fl X ;
275default is either
276.Ql dialog
277.Pq for Ql Fl D
278or
279.Ql Xdialog
280.Pq for Ql Fl X .
281.It Ev DIALOGRC
282If set and non-NULL, path to
283.Ql .dialogrc
284file.
285.It Ev HOME
286If
287.Ql Ev $DIALOGRC
288is either not set or NULL, used as a prefix to
289.Ql .dialogrc
290.Pq i.e., Ql $HOME/.dialogrc .
291.It Ev USE_COLOR
292If set and NULL, disables the use of color when using
293.Xr dialog 1
294.Pq does not apply to Xr Xdialog 1 .
295.El
296.Sh DEPENDENCIES
297If using
298.Ql Fl D ,
299.Xr dialog 1
300is required.
301.Pp
302If using
303.Ql Fl X ,
304.Xr Xdialog 1
305is required.
306.Sh FILES
307.Bl -tag -width ".Pa $HOME/.dialogrc" -compact
308.It Pa $HOME/.dialogrc
309.El
310.Sh EXAMPLES
311.Pp
312Simple example to show how fast
313.Xr yes 1
314produces lines
315.Pq usually about ten-million per-second; your results may vary :
316.Bd -literal -offset indent
317yes | dpv -l yes
318.Ed
319.Pp
320Display progress while timing how long it takes
321.Xr yes 1
322to produce a half-billion lines
323.Pq usually under one minute; your results may vary :
324.Bd -literal -offset indent
325time yes | dpv -Nl 500000000:yes
326.Ed
327.Pp
328An example to watch how quickly a file is transferred using
329.Xr nc 1 :
330.Bd -literal -offset indent
331dpv -x "nc -w 1 somewhere.com 3000" -m label file
332.Ed
333.Pp
334A similar example, transferring a file from another process and passing the
335expected size to
336.Nm :
337.Bd -literal -offset indent
338cat file | dpv -x "nc -w 1 somewhere.com 3000" 12345:label
339.Ed
340.Pp
341A more complicated example:
342.Bd -literal -offset indent
343tar cf - . | dpv -x "gzip -9 > out.tgz" \\
344	$( du -s . | awk '{print $1 * 1024}' ):label
345.Ed
346.Pp
347Taking an image of a disk:
348.Bd -literal -offset indent
349dpv -o disk-image.img -m label /dev/ada0
350.Ed
351.Pp
352Writing an image back to a disk:
353.Bd -literal -offset indent
354dpv -o /dev/ada0 -m label disk-image.img
355.Ed
356.Pp
357Zeroing a disk:
358.Bd -literal -offset indent
359dpv -o /dev/md42 < /dev/zero
360.Ed
361.Pp
362.Sh BUGS
363.Xr Xdialog 1 ,
364when given both
365.Ql Fl -title Ar title
366.Pq see above Ql Fl t Ar title
367and
368.Ql Fl -backtitle Ar backtitle
369.Pq see above Ql Fl b Ar backtitle ,
370displays the backtitle in place of the title and vice-versa.
371.Pp
372.Xr Xdialog 1
373does not wrap long prompt texts received after initial launch.
374This is a known issue with the
375.Ql --gauge
376widget in
377.Xr Xdialog 1 .
378.Pp
379.Xr dialog 1
380does not display the first character after a series of escaped escape-sequences
381(e.g., ``\\\\n'' produces ``\\'' instead of ``\\n'').
382This is a known issue with
383.Xr dialog 1
384and does not affect
385.Xr dialog 3
386or
387.Xr Xdialog 1 .
388.Pp
389If your application ignores
390.Ev USE_COLOR
391when set and NULL before calling
392.Xr dpv 1
393with color escape sequences anyway,
394.Xr dialog 3
395and
396.Xr dialog 1
397may not render properly.
398Workaround is to detect when
399.Ev USE_COLOR
400is set and NULL and either not use color escape sequences at that time or use
401.Xr unset 1
402.Xr [ sh 1 ]
403or
404.Xr unsetenv 1
405.Xr [ csh 1 ]
406to unset
407.Ev USE_COLOR ,
408forcing interpretation of color sequences.
409This does not effect
410.Xr Xdialog 1 ,
411which renders the color escape sequences as plain text.
412See
413.Do Li
414embedded "\\Z" sequences
415.Dc
416in
417.Xr dialog 1
418for additional information.
419.Sh SEE ALSO
420.Xr dialog 1 ,
421.Xr dialog 3 ,
422.Xr sh 1 ,
423.Xr Xdialog 1
424.Sh HISTORY
425A
426.Nm
427utility first appeared in
428.Fx 11.0 .
429.Sh AUTHORS
430.An Devin Teske Aq dteske@FreeBSD.org
431