Glabels-batch: allow project file to be provided on stdin. (#90)

This commit is contained in:
Jim Evins
2020-03-28 19:10:28 -04:00
parent 4a9f3aad8e
commit 142aaf2a92
5 changed files with 22 additions and 10 deletions
+12 -2
View File
@@ -44,10 +44,13 @@ namespace
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
const QString STDOUT_FILENAME = "CON:"; const QString STDOUT_FILENAME = "CON:";
const QString STDIN_FILENAME = "CON:";
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
const QString STDOUT_FILENAME = "/dev/stdout"; const QString STDOUT_FILENAME = "/dev/stdout";
const QString STDIN_FILENAME = "/dev/stdin";
#else #else
const QString STDOUT_FILENAME = "/dev/stdout"; const QString STDOUT_FILENAME = "/dev/stdout";
const QString STDIN_FILENAME = "/dev/stdin";
#endif #endif
} }
@@ -173,7 +176,14 @@ int main( int argc, char **argv )
if ( parser.positionalArguments().size() == 1 ) if ( parser.positionalArguments().size() == 1 )
{ {
qDebug() << "Batch mode.";
QString filename = parser.positionalArguments().constFirst(); QString filename = parser.positionalArguments().constFirst();
if ( filename == "-" )
{
filename = STDIN_FILENAME;
}
qDebug() << "Project file =" << filename;
glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename ); glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
if ( model ) if ( model )
@@ -184,7 +194,7 @@ int main( int argc, char **argv )
printer.setColorMode( QPrinter::Color ); printer.setColorMode( QPrinter::Color );
if ( parser.isSet("printer") ) if ( parser.isSet("printer") )
{ {
qDebug() << "Batch mode. printer =" << parser.value("printer"); qDebug() << "Printer =" << parser.value("printer");
printer.setPrinterName( parser.value("printer") ); printer.setPrinterName( parser.value("printer") );
} }
else if ( parser.isSet("output") ) else if ( parser.isSet("output") )
@@ -194,7 +204,7 @@ int main( int argc, char **argv )
{ {
outputFilename = STDOUT_FILENAME; outputFilename = STDOUT_FILENAME;
} }
qDebug() << "Batch mode. output =" << outputFilename; qDebug() << "Output =" << outputFilename;
printer.setOutputFileName( outputFilename ); printer.setOutputFileName( outputFilename );
} }
else else
+5 -4
View File
@@ -1,8 +1,8 @@
.\" Man page generated from reStructuredText. .\" 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 .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 .nr rst2man-indent-level 0
. .
@@ -32,11 +32,12 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.. ..
.SH SYNOPSIS .SH SYNOPSIS
.sp .sp
\fBglabels\-batch\-qt\fP [\fIoptions\fP] [\fIfilename\fP] \fBglabels\-batch\-qt\fP [\fIoptions\fP] \fIFILE\fP
.SH DESCRIPTION .SH DESCRIPTION
.sp .sp
\fBglabels\-batch\-qt\fP is a utility for printing a glabels project file \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 .SH OPTIONS
.INDENT 0.0 .INDENT 0.0
.TP .TP
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText. .\" Man page generated from reStructuredText.
. .
.TH "GLABELS-QT" "1" "Jan 02, 2020" "" "gLabels" .TH "GLABELS-QT" "1" "Mar 28, 2020" "" "gLabels"
.SH NAME .SH NAME
glabels-qt \- create labels and business cards glabels-qt \- create labels and business cards
. .
+1 -1
View File
@@ -150,7 +150,7 @@ latex_documents = [
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
('man/glabels-qt', 'glabels-qt', 'create labels and business cards', [], 1), ('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)
] ]
+3 -2
View File
@@ -4,13 +4,14 @@ glabels-batch-qt
SYNOPSIS SYNOPSIS
-------- --------
**glabels-batch-qt** [*options*] [*filename*] **glabels-batch-qt** [*options*] *FILE*
DESCRIPTION DESCRIPTION
----------- -----------
:program:`glabels-batch-qt` is a utility for printing a glabels project file :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 OPTIONS