labrat 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
data/README.org ADDED
@@ -0,0 +1,644 @@
1
+
2
+ #+BEGIN_COMMENT
3
+ This is for markdown output:
4
+
5
+ [![Build Status](https://travis-ci.org/ddoherty03/labrat.svg?branch=master)](https://travis-ci.org/ddoherty03/labrat)
6
+
7
+ The following is for org.
8
+ #+END_COMMENT
9
+
10
+ [[https://travis-ci.org/ddoherty03/labrat.svg?branch=master]]
11
+
12
+
13
+ * Table of Contents :toc_3:
14
+ - [[#labrat][Labrat]]
15
+ - [[#motivation][Motivation]]
16
+ - [[#a-tip-on-buying-file-folder-labels][A Tip on Buying File Folder Labels]]
17
+ - [[#installation][Installation]]
18
+ - [[#setting-options][Setting options]]
19
+ - [[#dimensions-and-other-values-in-options][Dimensions and other values in options]]
20
+ - [[#page-setup-options][Page Setup Options]]
21
+ - [[#orientation][Orientation]]
22
+ - [[#page-dimensions][Page Dimensions]]
23
+ - [[#page-grid][Page Grid]]
24
+ - [[#label-setup-options][Label Setup Options]]
25
+ - [[#padding][Padding]]
26
+ - [[#alignment][Alignment]]
27
+ - [[#fonts-and-styling][Fonts and styling]]
28
+ - [[#position-adjustment][Position Adjustment]]
29
+ - [[#job-processing-options][Job Processing Options]]
30
+ - [[#starting-label][Starting label]]
31
+ - [[#new-line-marker][New line marker]]
32
+ - [[#label-separator][Label separator]]
33
+ - [[#number-of-copies][Number of copies]]
34
+ - [[#input-and-output-files][Input and output files]]
35
+ - [[#printing-or-viewing][Printing or viewing]]
36
+ - [[#shell-commands][Shell commands]]
37
+ - [[#aids-to-testing-label-layouts][Aids to testing label layouts]]
38
+ - [[#the-label-database-and-the-label-option][The Label Database and the label option]]
39
+ - [[#listing-labels][Listing labels]]
40
+ - [[#system-label-database][System label database]]
41
+ - [[#trying-out-a-label-definition][Trying out a label definition]]
42
+ - [[#nesting-label-definitions][Nesting label definitions]]
43
+ - [[#label-database-entries-as-configuration-sets][Label database entries as configuration sets]]
44
+ - [[#a-caution-about-option-order][A Caution about option order]]
45
+ - [[#development][Development]]
46
+ - [[#contributing][Contributing]]
47
+
48
+ * Labrat
49
+ A linux command-line program for quickly printing labels. Labrat uses the
50
+ wonderful [[https://github.com/prawnpdf/prawn][Prawn gem]] to generate PDF files with label formatting in mind. With
51
+ =labrat= properly configured, printing a label is as simple as:
52
+
53
+ #+begin_example
54
+ $ labrat 'Income Taxes 2021++Example Maker, Inc.'
55
+ #+end_example
56
+
57
+ And you will get a two-line file-folder label printed that looks like this:
58
+
59
+ [[./img/sample.png]]
60
+
61
+ Note that an outline was added to make the size of the label apparent and is
62
+ not actually printed with the label by default.
63
+
64
+ ** Motivation
65
+ I need to print labels. And in my case, mostly I need file folder labels. I
66
+ typically want to print to a Dymo LabelWriter, of which I own several
67
+ variants. The problem is that I work almost entirely in Linux, but the simple
68
+ task of printing a file folder label has required opening a GUI application,
69
+ such as the very fine [[https://help.gnome.org/users/glabels/stable/][glabels]], or worse, switching to a machine running
70
+ Windows or to a Mac to run Dymo's proprietary GUI. The Dymo GUI is
71
+ particularly irksome because it takes a long time to start up and demands that
72
+ you register every time you open it.
73
+
74
+ I wanted a way to print a file label from the command line, or even better,
75
+ from within my editor, Emacs. After giving up looking for such a thing
76
+ without success, I decided to write my own. Hence labrat. With it---after
77
+ due configuration---printing a file folder label is as simple as:
78
+
79
+ #+begin_src sh
80
+ $ labrat 'First Line of Label++And the Second Line'
81
+ #+end_src
82
+
83
+ Or, you can preview the label in your previewer of choice (mine is qpdfview)
84
+ by adding the -V flag:
85
+
86
+ #+begin_src sh
87
+ $ labrat -V 'First Line of Label++And the Second Line'
88
+ #+end_src
89
+
90
+ Even better, I have included with =labrat= an elisp file (=labrat.el=) that
91
+ will invoke =labrat= to form a label with the text of the paragraph at or
92
+ before point. So within Emacs, you can bind keys to the commands,
93
+ =labrat-print= and =labrat-view= to print or view the current or prior
94
+ paragraph as your default label. Thus, in Emacs, I have ~C-z C-l C-l~ bound
95
+ to =labrat-print= and ~C-z C-l C-v~ to =labrat-view=, and I can type a label
96
+ in any buffer and get it generated with very little ceremony.
97
+
98
+ ** A Tip on Buying File Folder Labels
99
+ As mentioned, one of my main motivations for writing =labrat= was the need to
100
+ easily create file-folder labels. I got into creating files after reading
101
+ /Getting Things Done/ by David Allen. One of his recommendations for keeping
102
+ organized is having a file system so that documents can be easily archived and
103
+ retrieved.
104
+
105
+ I have long used Dymo's 30327 label, which is just the right size for file
106
+ folders. But after several years of use, I started to notice something
107
+ alarming: I could no longer read the text of the labels, they had nearly faded
108
+ into oblivion. The problem is that the labels use a thermal printing
109
+ technology that is affected by light and time, and over a period of years,
110
+ they get lighter and lighter. You may have seen the same thing on old
111
+ thermal-printed store receipts.
112
+
113
+ After looking for alternative printers, I found the solution, not in a new
114
+ printer technology, but in a new label technology. DuraReady makes labels
115
+ that can be printed on a thermal printer like the Dymo LaserWriter, but print
116
+ on a "Gloss white polypropylene BOPP plastic." I'm not sure what that is, but
117
+ the labels come out with nice black lettering on a white background, and they
118
+ don't fade. Check it out here: [[https://www.duraready.com/file-folder-labels/1034d-9/16-x-3-7/16-white-bopp-plastic-label/][DuraReady]].
119
+
120
+ Thermal labels may be fine for ephemeral applications like name tags or
121
+ shipping labels, but are terrible for long-term applications like file
122
+ folders, marking cables, marking electrical breakers, or any other number of
123
+ applications where long-term readability is essential.
124
+
125
+ ** Installation
126
+ Since =labrat= is distributed as a Ruby gem, you have to have a ruby
127
+ installation. Look [[https://www.ruby-lang.org/en/documentation/installation/][here]] for ruby installation instructions. You can then
128
+ install =labrat= with:
129
+
130
+ #+begin_SRC sh
131
+ $ gem install labrat
132
+ #+end_SRC
133
+
134
+ After installation, you should install the user and system configuration files
135
+ with:
136
+
137
+ #+begin_SRC sh
138
+ $ labrat-install
139
+ #+end_SRC
140
+
141
+ This will install an annotated system-wide config file in
142
+ =/etc/xdg/labrat/config.yml= and a system-wide label database in
143
+ =/etc/xdg/labrat/labeldb.yml=.
144
+
145
+ It will also install an annotated sample user config file in
146
+ =~/.config/labrat/labrat.el= and a sample user-level label database in
147
+ =~/.config/labrat/labeldb.yml=.
148
+
149
+ For the benefit of Emacs users, it also installs the =labrat.el= elisp library
150
+ in =~/.config/labrat= as well, though you may want to move it to a different
151
+ location.
152
+
153
+ If invoke =labrat-install= multiple times, it will refuse to overwrite any
154
+ existing config or database files that you may have edited. If you want to
155
+ re-install them you have to move them out of the way.
156
+
157
+ ** Setting options
158
+ You can control how =labrat= composes a label completely from the
159
+ command-line, though that would be a very tedious thing to have to do.
160
+ Better, set up your preferred configuration in your user config file, so that
161
+ all you need to supply on the command line is the text of the label. Every
162
+ command-line option has an equivalent configuration option using the long form
163
+ of the option as a key in a YAML configuration format.
164
+
165
+ Labrat reads options from the following locations, with the locations listed
166
+ from lowest to highest priority. In other words, options set in the
167
+ first-listed location can be overriden by settings in later-listed locations.
168
+
169
+ 1. It reads system-wide options from =/etc/xdg/labrat/config.yml=. This is a
170
+ YAML formatted file in which the long form of the option, without the
171
+ leading '--', is used as a key with the setting as the value.
172
+ 2. It reads a user configuration from =~/.config/labrat/config.yml=. It also
173
+ uses the YAML format based on the long form of option names.
174
+ 3. Finally, it reads options from the command-line, where, of course, the
175
+ leading hyphens are mandatory.
176
+
177
+ ** Dimensions and other values in options
178
+ Many of the options deal with specifying some sort of distance. Those are
179
+ designated with the placeholder ~DIM~. A ~DIM~ is an integer or floating
180
+ point number followed by an optional unit of measurement. If no unit is
181
+ given, the unit ~pt~ for "points" are assumed. Here are the valid units that
182
+ you can use:
183
+
184
+ - ~pt~ :: Points, or Adobe points, or "big points", equal to exactly 1/72 of
185
+ an inch, the default if no unit is given
186
+ - ~mm~ :: Millimeters,
187
+ - ~cm~ :: Centimeters, equal to 10 millimeters,
188
+ - ~dm~ :: Decimeters, equal to 10 centimeters,
189
+ - ~in~ :: Inches,
190
+ - ~ft~ :: Feet, equal to 12 inches,
191
+ - ~yd~ :: Yard, equal to 3 feet.
192
+
193
+ Most other options are strings, which need to be quoted on the command-line if
194
+ they contain any spaces or other characters special to your shell. In the
195
+ configuration files, string values need not be quoted.
196
+
197
+ ** Page Setup Options
198
+ Labrat can handle multi-label pages such as Avery-style label sheets. These
199
+ options deal with the page-level dimensions of the, potentially, multi-label
200
+ page. By contrast, the dimensions of individual labels are dealt with by the
201
+ label setup options described in the next section.
202
+
203
+ *** Orientation
204
+ - ~-L~, ~--[no-]landscape~ :: Orient the label grid and the printing direction
205
+ of the text of the label in landscape (default false), i.e., with the label
206
+ grid rotated 90 degrees clockwise so that the first label is printed down
207
+ the page starting at the upper right element of the grid. This setting does
208
+ not affect what is left, right, top, or bottom for purposes of specifying
209
+ the page dimensions, but does affect what is considered "horizontal rows"
210
+ and "vertical columns": those are counted in the rotated direction of
211
+ printing.
212
+ - ~-P~, ~--[no-]portrait~ :: This is simply a convenience switch meaning
213
+ ~--no-landscape~ and is the default.
214
+
215
+ *** Page Dimensions
216
+ When specifying page dimensions, =labrat= regards all dimension-related
217
+ directions, left, right, top, bottom to refer to the page as is comes out of
218
+ the printer, unaffected by whether the labels are printed in landscape or
219
+ portrait. This hopefully eliminates some confusion in the use of those terms.
220
+ Even a specialty label printer, such as the Dymo LabelWriter series, in which
221
+ the long skinny labels come out of the printer sideways, regard the page
222
+ dimensions in the orientation that the labels come out: that is, the "page"
223
+ has a relatively narrow width compared to its tall height.
224
+
225
+ With that in mind, specifying the page dimensions is just a matter of getting
226
+ out a ruler and measuring.
227
+
228
+ - ~-w~, ~--page-width=DIM~ :: Horizontal dimension of a page of labels as it
229
+ comes out of the printer
230
+ - ~-h~, ~--page-height=DIM~ :: Vertical dimension of a page of labels as it
231
+ comes out of the printer
232
+ - ~--top-page-margin=DIM~ :: Distance from top side of page (in portrait) to
233
+ the print area
234
+ - ~--bottom-page-margin=DIM~ :: Distance from bottom side of page (in
235
+ portrait) to the print area
236
+ - ~--left-page-margin=DIM~ :: Distance from left side of page (in portrait) to
237
+ the print area
238
+ - ~--right-page-margin=DIM~ :: Distance from right side of page (in portrait)
239
+ to the print area
240
+ - ~--v-page-margin=DIM~ :: Distance from top and bottom sides of page (in
241
+ portrait) to the print area; short for ~--top-page-margin~ and
242
+ ~--bottom-page-margin~
243
+ - ~--h-page-margin=DIM~ :: Distance from left and right sides of page (in
244
+ portrait) to the print area; short for ~--left-page-margin~ and
245
+ ~--right-page-margin~
246
+ - ~--page-margin=DIM~ :: Distance from all sides of page (in portrait) to the
247
+ print area; short for ~--top-page-margin~, ~--bottom-page-margin~,
248
+ ~--left-page-margin~ and ~--right-page-margin~
249
+
250
+ *** Page Grid
251
+ By default, =labrat= considers a page of labels to contain only one row and
252
+ one column, that is, a single label per page. To set up a multi-label page,
253
+ you have to describe the number of rows and columns and the amount of the gap
254
+ between them. The number of "rows" is counted as the number of "horizontal"
255
+ set of labels after taking the page orientation into account. Likewise, the
256
+ number of columns is counted as the number of "vertical" set of labels after
257
+ taking the page orientation into account
258
+
259
+ - ~-R~, ~--rows=NUM~ :: The number of horizontal rows of labels on a page, taking
260
+ into account the direction of printing via the ~--landscape~ switch.
261
+ - ~-C~, ~--columns=NUM~ :: The number of vertical columns of labels on a page,
262
+ taking into account the direction of printing via the ~--landscape~ switch.
263
+ - ~--row-gap=DIM~ :: The distance between rows of labels on a page
264
+ - ~--column-gap=DIM~ :: The distance between columns of labels on a page
265
+
266
+ ** Label Setup Options
267
+ These options determine the layout of individual labels within the page rather
268
+ than the page as a whole. Note that the dimensions of individual labels is
269
+ not specified, but is implicitly determined by (1) the page width and height,
270
+ (2) the page margins, (3) the number of rows and columns per page, and (4) the
271
+ row and column gaps. The remaining space on the page is divided into a grid
272
+ of identically-sized labels, which determines the size of each label.
273
+
274
+ *** Padding
275
+ Within each label, the following options allow you to set the margins on each
276
+ side of the label:
277
+
278
+ - ~--top-pad=DIM~ :: Distance from top side of label to the printed text
279
+ - ~--bottom-pad=DIM~ :: Distance from bottom side of label to the printed text
280
+ - ~--left-pad=DIM~ :: Distance from left side of label to the printed text
281
+ - ~--right-pad=DIM~ :: Distance from right side of label to the printed text
282
+ - ~--v-pad=DIM~ :: Short for ~--top-pad=DIM~ and ~--bottom-pad~
283
+ - ~--h-pad=DIM~ :: Short for ~--left-pad=DIM~ and ~--right-pad~
284
+ - ~--pad=DIM~ :: Short for ~--top-pad=DIM~, ~--bottom-pad~, ~--left-pad=DIM~
285
+ and ~--right-pad~
286
+
287
+ *** Alignment
288
+ By default the label text is centered horizontally and vertically within the
289
+ label, but the following options allow you to alter that.
290
+
291
+ - ~--h-align=[left|center|right|justify]~ :: Horizontal alignment of text
292
+ within the label (default center);
293
+ - ~--v-align=[top|center|bottom]~ :: Vertical alignment of text within the
294
+ label (default center)
295
+
296
+ *** Fonts and styling
297
+ =labrat= provides a few simple mean for styling the label text. Note that all
298
+ of these apply to the whole label text: there is no provision yet for doing
299
+ in-line changes of font styles.
300
+
301
+ - ~--font-name=NAME~ :: Name of font to use, Times, Courier, or Helvetica
302
+ (default Helvetica);
303
+ - ~--font-size=NUM~ :: Size of font to use in points (default 12)
304
+ - ~--font-style=[normal|bold|italic|bold-italic]~ :: Style of font to use for
305
+ text (default normal)
306
+
307
+ *** Position Adjustment
308
+ Despite our best efforts, the vagaries of printer hardware, print drivers, and
309
+ cosmic rays, sometimes the text of the label is not positioned correctly
310
+ within the printable area of the label. These options allow you to nudge the
311
+ print area left or right, up or down a bit to compensate for any such
312
+ anomalies.
313
+
314
+ - ~-x, --delta-x=DIM~ :: Left-right adjustment (positive moves right, negative
315
+ left) of label text within the label print area.
316
+ - ~-y, --delta-y=DIM~ :: Up-down adjustment (positive moves up, negative
317
+ down) of label text within the label print area.
318
+
319
+ ** Job Processing Options
320
+ The following options control the processing of labels by =labrat=.
321
+
322
+ *** Starting label
323
+ When printing onto a multi-label page, some of the labels may have already
324
+ been used. In that case, the ~--start-label~ option allows you to tell
325
+ =labrat= to start printing at some later label on the page. The label
326
+ positions are numbered from 1 up to the number of labels per page (i.e., rows
327
+ times columns) from left to right and down the page. If you want to print a
328
+ sheet that shows the label numbers, see the ~-T~ template option below.
329
+
330
+ - ~-S NUM~, ~--start-label=NUM~ :: Start printing at label number NUM (starting
331
+ at 1, left-to-right, top-to-bottom) within first page only. Later pages
332
+ always start at label 1.
333
+
334
+ This only affects the placement of the first label on the first page. Any
335
+ later pages always start on the first label position.
336
+
337
+ *** New line marker
338
+ You can embed a special text-sequence in the label text to indicate where a
339
+ line-break should occur. By default it is the sequence =++=. This means that
340
+ =labrat= will translate all occurrences of =++= in the text into a line-break,
341
+ even consecutive occurrences. There is no way to escape this in the text, so
342
+ if you want labels for various programming languages, you are going to have
343
+ difficulty printing a label with 'C++' in it. But you can change the marker
344
+ to something else with ~--nlsep~. This is especially helpful when you are
345
+ using the command-line to supply the label text since specifying line-breaks
346
+ on a shell command can be difficult. However note that this substitution
347
+ takes place even when reading label texts from a file or standard input.
348
+
349
+ - ~-n~, ~--nlsep=SEPARATOR~ :: Specify text to be translated into a line-break
350
+ (default '++')
351
+
352
+ *** Label separator
353
+ The only way to print more than one label from the command-line is to indicate
354
+ where one label ends and the next begins with a special marker in the
355
+ command-line arguments, by default the string ']*['. The text used for this
356
+ can be customized with this option.
357
+
358
+ - ~--label-sep=SEPARATOR~ :: Specify text that indicates the start of a new
359
+ label (default ']*[')
360
+
361
+ *** Number of copies
362
+ This option causes =labrat= to generate multiple copies of each label with all
363
+ the copies printed sequentially on the page.
364
+
365
+ - ~-c NUM~, ~--copies=NUM~ :: Number of copies of each label to generate.
366
+
367
+ *** Input and output files
368
+ **** Output file
369
+ By default, =labrat= generates all the labels into a single PDF file called
370
+ 'labrat.pdf' in the current directory. You can specify a different output
371
+ file with the ~--out-file~ option.
372
+
373
+ - ~-o~, ~--out-file=FILENAME~ :: Put generated label in the given file
374
+
375
+ **** Command-line arguments
376
+ By default, =labrat= gets the text of the label from the non-option arguments
377
+ on the command-line. It combines all the non-option arguments and joins them
378
+ with a space between each argument. For example,
379
+
380
+ #+begin_example
381
+ $ labrat -c3 This is a 'single label' '++composed of all this' text --font-style=italic
382
+ #+end_example
383
+
384
+ prints three copies of a single label in italics with two lines, breaking at
385
+ the '++' marker, resulting in something like this:
386
+
387
+ #+begin_example
388
+ This is a single label
389
+ composed of all this text
390
+ #+end_example
391
+
392
+ Note that when the label text is specified on the command-line, ~labrat~ just
393
+ prints a single label. The only ways to get multiple labels is by (1) marking
394
+ a separation between labels with the ~--label-sep~ marker (']*[' by default)
395
+ or (2) using the ~-c~ (~--copies~) argument to get multiple copies of the
396
+ label text. These options can be combined as well. For example,
397
+
398
+ #+begin_example
399
+ $ labrat -c3 This is the 'first label' ']*[' 'And the rest ++ is the second' text --font-style=italic
400
+ #+end_example
401
+
402
+ will produce three copies of two separate labels:
403
+
404
+ #+begin_example
405
+ This is a the first label
406
+
407
+ This is a the first label
408
+
409
+ This is a the first label
410
+
411
+ And the rest
412
+ is the second
413
+
414
+ And the rest
415
+ is the second
416
+
417
+ And the rest
418
+ is the second
419
+ #+end_example
420
+
421
+ **** Specified input file
422
+ Rather than get the text from the non-option arguments on the command line,
423
+ you can use the ~--in-file~ option to specify that label texts are to be read
424
+ from the given file instead.
425
+
426
+ Each paragraph in the file constitutes a separate label. Line breaks within
427
+ the paragraphs are respected, though the ~--nlsep~ marker is still replaced
428
+ with additional line breaks. Any line starting with a ~#~ character is
429
+ considered a comment and is not included in the text of any label.
430
+
431
+ - ~-f~, ~--in-file=FILENAME~ :: Read labels from given file instead of
432
+ command-line
433
+
434
+ **** Standard input
435
+ Only if there are no non-option arguments and no ~in-file~ specified, =labrat=
436
+ acts as a filter and reads the label texts from standard input in same manner
437
+ as for a specified ~in-file~, treating each paragraph as a label text and
438
+ disregarding comments.
439
+
440
+ **** Template exception
441
+ Notwithstanding all of the above, if the ~-T~ (~--template~) option is given,
442
+ all label texts from the command-line, an ~in-file~, or standard input are
443
+ ignored and a template is generated.
444
+
445
+ *** Printing or viewing
446
+ By default, =labrat= prints the generated output file to the printer named
447
+ with the ~--printer~ option using the shell command specified in the
448
+ ~--print-command~ option. But with the ~--view~ option, it will use the shell
449
+ command from ~--view-command~ to view the generated PDF file instead.
450
+
451
+ - ~-V~, ~--[no-]view~ :: View rather than print
452
+
453
+ *** Shell commands
454
+ By default, =labrat= uses the shell command:
455
+ #+begin_example
456
+ lpr -P %p %o
457
+ #+end_example
458
+ to print, and substitutes '%p' with the printer name and '%o' with the output
459
+ file name. But you can specify a different print command with the
460
+ ~--print-command~ option. The printer name used in the substitution is by
461
+ default taken from the environment variable =LABRAT_PRINTER= if it is defined,
462
+ or from the environment variable =PRINTER= if it is defined and
463
+ =LABRAT_PRINTER= is not defined. If neither is defined, it defaults to the
464
+ name 'dymo'. But you can set the printer name with the ~--printer~ option in
465
+ any event.
466
+
467
+ - ~-p~, ~--printer=NAME~ :: Name of the label printer to print on
468
+ - ~-%~, ~--print-command=PRINTCMD~ :: Command to use for printing with %p for
469
+ printer name; %o for label file name
470
+
471
+ Likewise, =labrat= uses the shell command
472
+ #+begin_example
473
+ qpdfview --unique --instance labrat %o'
474
+ #+end_example
475
+ to launch the previewer when the ~--view~ or ~-V~ options are given. It also
476
+ '%o' with the output file name, but does not recognize '%p' as special. It is
477
+ very likely that you will want to configure this with the ~--view-command~
478
+ option to your liking.
479
+
480
+ - ~-:~, ~--view-command=VIEWCMD~ :: Command to use for viewing with %o for
481
+ label file name
482
+
483
+ *** Aids to testing label layouts
484
+ The following options are very useful if your are trying to configure the set
485
+ up for a new label type or otherwise trying to figure out a problem.
486
+ Normally, =labrat= does not print an outline for the labels, but if you are
487
+ testing things out on plain paper, it helps to know where =labrat= thinks the
488
+ boundaries of the labels are. That is what the ~--grid~ or ~-g~ options
489
+ provide.
490
+
491
+ - ~-g~, ~--[no-]grid~ :: Add grid lines to output
492
+
493
+ When trying to define a new label layout, it also helps to just see what a
494
+ single sheet of labels would look like. That is what the ~--template~ or ~-T~
495
+ option give you: it just prints an outline of where labels would be printed
496
+ but ignores any label text.
497
+
498
+ - ~-T~, ~--[no-]template~ :: Print a template of a page of labels and ignore
499
+ any content
500
+
501
+ Finally, =labrat= will print a lot of information about what it's doing with
502
+ the ~--verbose~ or ~-v~ option. The information is printed to the standard
503
+ error output stream.
504
+
505
+ - ~-v~, ~--[no-]verbose~ :: Run verbosely, that is, print out lots of
506
+ information about what =labrat= is doing as it processes the job.
507
+
508
+ ** The Label Database and the label option
509
+ One of the nice things about =labrat= is that it comes with a database of
510
+ pre-defined label configurations for many standard labels, especially Avery
511
+ labels since they are kind enough to publish PDF templates for all their
512
+ products at [[https://www.avery.com/templates]].
513
+
514
+ *** Listing labels
515
+ You can get =labrat= to list all the labels it knows about with
516
+ #+begin_example
517
+ $ labrat --list-labels
518
+ #+end_example
519
+
520
+ Any users who create useful label definitions can propose them for inclusion
521
+ with =labrat's= distributed label database by filing a pull request at this
522
+ git repository.
523
+
524
+ *** System label database
525
+ Here for example is the definition for Avery 8987 labels from the system
526
+ database:
527
+ #+begin_example
528
+ avery8987:
529
+ page-width: 8.5in
530
+ page-height: 11in
531
+ rows: 10
532
+ columns: 3
533
+ top-page-margin: 15mm
534
+ bottom-page-margin: 16mm
535
+ left-page-margin: 10mm
536
+ right-page-margin: 10mm
537
+ row-gap: 6.3mm
538
+ column-gap: 13mm
539
+ landscape: false
540
+ #+end_example
541
+
542
+ Note that it restricts itself to page-level settings. It would be
543
+ inappropriate to, for example, include something like ~font-style~ in a
544
+ system-wide label definition, though such things can be useful in a user's
545
+ private label configuration.
546
+
547
+ *** Trying out a label definition
548
+ You can see the result of this definition by using =labrat's= ~--template~ and
549
+ ~--view~ options, like this:
550
+ #+begin_example
551
+ $ labrat -T -V --label=avery8987
552
+ #+end_example
553
+
554
+ And if you want to see it with sample label text filled in, try the following:
555
+ #+begin_example
556
+ $ labrat -V -c30 --label=avery8987 'Four score and seven years ago++Our fathers brought forth'
557
+ #+end_example
558
+
559
+ *** Nesting label definitions
560
+ As it happens, Avery 8986 is laid out identically to Avery 8987, and the label
561
+ database makes an alias for it like this:
562
+ #+begin_example
563
+ avery8986:
564
+ label: avery8987
565
+ #+end_example
566
+ In other words, it defines the ~avery8986~ label with a nested ~--label~
567
+ option that simply refers to the ~avery8987~ entry.
568
+
569
+ *** Label database entries as configuration sets
570
+ This ability to use a label database definition as an alias for a whole set of
571
+ other configuration options allows you to add entries to your user-level label
572
+ database to collect useful sets of configuration settings under a name of your
573
+ choosing. Here for example, are entries from my user-level database at
574
+ =~/.config/labrat/labeldb.yml= file that define the configuration for file
575
+ folders and badges:
576
+ #+begin_example
577
+ ff:
578
+ label: duraready1034D
579
+ font-style: bold
580
+ font-size: 12pt
581
+ delta-x: -3mm
582
+ delta-y: 0.5mm
583
+
584
+ badge:
585
+ label: avery18662
586
+ font-style: bold
587
+ font-size: 18pt
588
+ #+end_example
589
+
590
+ With this, you can print a file folder label with:
591
+ #+begin_example
592
+ $ labrat --label=ff 'Four score and seven years ago++Our fathers brought forth'
593
+ #+end_example
594
+
595
+ And, if you want this to be your default label type, you can add to your user-level
596
+ config file, an entry like this:
597
+ #+begin_example
598
+ label:
599
+ ff
600
+ #+end_example
601
+
602
+ Now you can print the label without the ~--label~ option on the command-line:
603
+ #+begin_example
604
+ $ labrat 'Four score and seven years ago++Our fathers brought forth'
605
+ #+end_example
606
+
607
+ If you want to print badges, you have to specify the ~--label~ option explicitly on
608
+ the command-line:
609
+ #+begin_example
610
+ $ labrat -V -c14 --label=badge 'Daniel E. Doherty++(Amateur Programmer)'
611
+ #+end_example
612
+
613
+ *** A Caution about option order
614
+ Note that =labrat= processes options from the system config file, the user
615
+ config file, and the command-line strictly in order so that later settings
616
+ override earlier settings. For example, given the configuration above, where
617
+ ~ff~ is your default label type, the following will not do what you expect:
618
+
619
+ #+begin_example
620
+ $ labrat --font-style=italic --label=ff 'Four score and seven years ago++Our fathers brought forth'
621
+ #+end_example
622
+
623
+ You expect the label to be printed in italic, but the ~--label=ff~ option in
624
+ effect inserts all the settings for label type ~ff~ at that point in the
625
+ command-line, and thus overrides the ~--font-style~ setting with its own,
626
+ namely ~--font-style=bold~ from the user-level label database.
627
+
628
+ To get this to work, you have to put the command-line setting after the
629
+ ~--label=ff~ option in order for it to take effect:
630
+ #+begin_example
631
+ $ labrat --label=ff --font-style=italic 'Four score and seven years ago++Our fathers brought forth'
632
+ #+end_example
633
+
634
+ * Development
635
+ After checking out the repo, run `bin/setup` to install dependencies. Then,
636
+ run `rake spec` to run the tests. You can also run `bin/console` for an
637
+ interactive prompt that will allow you to experiment.
638
+
639
+ To install this gem onto your local machine, run `bundle exec rake
640
+ install`.
641
+
642
+ * Contributing
643
+ Bug reports and pull requests are welcome on GitHub at
644
+ https://github.com/ddoherty03/labrat.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec]
data/TODO.org ADDED
@@ -0,0 +1,7 @@
1
+ 1. Include aliases for labels in the db, or perhaps allow one label command to
2
+ include another label command, provided infinite recursion does not occur.
3
+ Perhaps check depth of reference?
4
+ 2. Include a --list command to list all known label types.
5
+ 3. Include verbose diagnostics for each phase of label production: read
6
+ configs (say which were found), read labeldb (say where found), read
7
+ command-line arguments (echo those found), echo non-opts argument.
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "labrat"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ require "pry"
12
+ Pry.start
13
+
14
+ # require "irb"
15
+ # IRB.start(__FILE__)