Skip to content

Commit

Permalink
Glabels-batch: allow project file to be provided on stdin. (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevins committed Mar 28, 2020
1 parent 4a9f3aa commit 142aaf2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
14 changes: 12 additions & 2 deletions glabels-batch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ namespace

#if defined(Q_OS_WIN)
const QString STDOUT_FILENAME = "CON:";
const QString STDIN_FILENAME = "CON:";
#elif defined(Q_OS_LINUX)
const QString STDOUT_FILENAME = "/dev/stdout";
const QString STDIN_FILENAME = "/dev/stdin";
#else
const QString STDOUT_FILENAME = "/dev/stdout";
const QString STDIN_FILENAME = "/dev/stdin";
#endif

}
Expand Down Expand Up @@ -173,7 +176,14 @@ int main( int argc, char **argv )

if ( parser.positionalArguments().size() == 1 )
{
qDebug() << "Batch mode.";

QString filename = parser.positionalArguments().constFirst();
if ( filename == "-" )
{
filename = STDIN_FILENAME;
}
qDebug() << "Project file =" << filename;

glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
if ( model )
Expand All @@ -184,7 +194,7 @@ int main( int argc, char **argv )
printer.setColorMode( QPrinter::Color );
if ( parser.isSet("printer") )
{
qDebug() << "Batch mode. printer =" << parser.value("printer");
qDebug() << "Printer =" << parser.value("printer");
printer.setPrinterName( parser.value("printer") );
}
else if ( parser.isSet("output") )
Expand All @@ -194,7 +204,7 @@ int main( int argc, char **argv )
{
outputFilename = STDOUT_FILENAME;
}
qDebug() << "Batch mode. output =" << outputFilename;
qDebug() << "Output =" << outputFilename;
printer.setOutputFileName( outputFilename );
}
else
Expand Down
9 changes: 5 additions & 4 deletions user-docs/_build/man/glabels-batch-qt.1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.\" Man page generated from reStructuredText.
.
.TH "GLABELS-BATCH-QT" "1" "Jan 02, 2020" "" "gLabels"
.TH "GLABELS-BATCH-QT" "1" "Mar 28, 2020" "" "gLabels"
.SH NAME
glabels-batch-qt \- batch creation of labels and business cards
glabels-batch-qt \- print glabels project from command line
.
.nr rst2man-indent-level 0
.
Expand Down Expand Up @@ -32,11 +32,12 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
..
.SH SYNOPSIS
.sp
\fBglabels\-batch\-qt\fP [\fIoptions\fP] [\fIfilename\fP]
\fBglabels\-batch\-qt\fP [\fIoptions\fP] \fIFILE\fP
.SH DESCRIPTION
.sp
\fBglabels\-batch\-qt\fP is a utility for printing a glabels project file
from the command line. It is suitable for use with scripts.
from the command line. This command takes exactly one project file, FILE. If FILE
is "\-", it expects an XML glabels project to be provided on standard input.
.SH OPTIONS
.INDENT 0.0
.TP
Expand Down
2 changes: 1 addition & 1 deletion user-docs/_build/man/glabels-qt.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "GLABELS-QT" "1" "Jan 02, 2020" "" "gLabels"
.TH "GLABELS-QT" "1" "Mar 28, 2020" "" "gLabels"
.SH NAME
glabels-qt \- create labels and business cards
.
Expand Down
2 changes: 1 addition & 1 deletion user-docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
# (source start file, name, description, authors, manual section).
man_pages = [
('man/glabels-qt', 'glabels-qt', 'create labels and business cards', [], 1),
('man/glabels-batch-qt', 'glabels-batch-qt', 'batch creation of labels and business cards', [], 1)
('man/glabels-batch-qt', 'glabels-batch-qt', 'print glabels project from command line', [], 1)
]


Expand Down
5 changes: 3 additions & 2 deletions user-docs/man/glabels-batch-qt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ glabels-batch-qt
SYNOPSIS
--------

**glabels-batch-qt** [*options*] [*filename*]
**glabels-batch-qt** [*options*] *FILE*

DESCRIPTION
-----------

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


OPTIONS
Expand Down

0 comments on commit 142aaf2

Please sign in to comment.