Skip to content

Commit 142aaf2

Browse files
committed
Glabels-batch: allow project file to be provided on stdin. (#90)
1 parent 4a9f3aa commit 142aaf2

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

Diff for: glabels-batch/main.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ namespace
4444

4545
#if defined(Q_OS_WIN)
4646
const QString STDOUT_FILENAME = "CON:";
47+
const QString STDIN_FILENAME = "CON:";
4748
#elif defined(Q_OS_LINUX)
4849
const QString STDOUT_FILENAME = "/dev/stdout";
50+
const QString STDIN_FILENAME = "/dev/stdin";
4951
#else
5052
const QString STDOUT_FILENAME = "/dev/stdout";
53+
const QString STDIN_FILENAME = "/dev/stdin";
5154
#endif
5255

5356
}
@@ -173,7 +176,14 @@ int main( int argc, char **argv )
173176

174177
if ( parser.positionalArguments().size() == 1 )
175178
{
179+
qDebug() << "Batch mode.";
180+
176181
QString filename = parser.positionalArguments().constFirst();
182+
if ( filename == "-" )
183+
{
184+
filename = STDIN_FILENAME;
185+
}
186+
qDebug() << "Project file =" << filename;
177187

178188
glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
179189
if ( model )
@@ -184,7 +194,7 @@ int main( int argc, char **argv )
184194
printer.setColorMode( QPrinter::Color );
185195
if ( parser.isSet("printer") )
186196
{
187-
qDebug() << "Batch mode. printer =" << parser.value("printer");
197+
qDebug() << "Printer =" << parser.value("printer");
188198
printer.setPrinterName( parser.value("printer") );
189199
}
190200
else if ( parser.isSet("output") )
@@ -194,7 +204,7 @@ int main( int argc, char **argv )
194204
{
195205
outputFilename = STDOUT_FILENAME;
196206
}
197-
qDebug() << "Batch mode. output =" << outputFilename;
207+
qDebug() << "Output =" << outputFilename;
198208
printer.setOutputFileName( outputFilename );
199209
}
200210
else

Diff for: user-docs/_build/man/glabels-batch-qt.1

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH "GLABELS-BATCH-QT" "1" "Jan 02, 2020" "" "gLabels"
3+
.TH "GLABELS-BATCH-QT" "1" "Mar 28, 2020" "" "gLabels"
44
.SH NAME
5-
glabels-batch-qt \- batch creation of labels and business cards
5+
glabels-batch-qt \- print glabels project from command line
66
.
77
.nr rst2man-indent-level 0
88
.
@@ -32,11 +32,12 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
3232
..
3333
.SH SYNOPSIS
3434
.sp
35-
\fBglabels\-batch\-qt\fP [\fIoptions\fP] [\fIfilename\fP]
35+
\fBglabels\-batch\-qt\fP [\fIoptions\fP] \fIFILE\fP
3636
.SH DESCRIPTION
3737
.sp
3838
\fBglabels\-batch\-qt\fP is a utility for printing a glabels project file
39-
from the command line. It is suitable for use with scripts.
39+
from the command line. This command takes exactly one project file, FILE. If FILE
40+
is "\-", it expects an XML glabels project to be provided on standard input.
4041
.SH OPTIONS
4142
.INDENT 0.0
4243
.TP

Diff for: user-docs/_build/man/glabels-qt.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH "GLABELS-QT" "1" "Jan 02, 2020" "" "gLabels"
3+
.TH "GLABELS-QT" "1" "Mar 28, 2020" "" "gLabels"
44
.SH NAME
55
glabels-qt \- create labels and business cards
66
.

Diff for: user-docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
# (source start file, name, description, authors, manual section).
151151
man_pages = [
152152
('man/glabels-qt', 'glabels-qt', 'create labels and business cards', [], 1),
153-
('man/glabels-batch-qt', 'glabels-batch-qt', 'batch creation of labels and business cards', [], 1)
153+
('man/glabels-batch-qt', 'glabels-batch-qt', 'print glabels project from command line', [], 1)
154154
]
155155

156156

Diff for: user-docs/man/glabels-batch-qt.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ glabels-batch-qt
44
SYNOPSIS
55
--------
66

7-
**glabels-batch-qt** [*options*] [*filename*]
7+
**glabels-batch-qt** [*options*] *FILE*
88

99
DESCRIPTION
1010
-----------
1111

1212
:program:`glabels-batch-qt` is a utility for printing a glabels project file
13-
from the command line. It is suitable for use with scripts.
13+
from the command line. This command takes exactly one project file, FILE. If FILE
14+
is "-", it expects an XML glabels project to be provided on standard input.
1415

1516

1617
OPTIONS

0 commit comments

Comments
 (0)