Command Line Interface
auto-print provides two command-line interfaces:
Configuration Generator: For setting up printer configurations
Print Executor: For printing files based on the configuration
Configuration Generator
Interactive configuration generator for auto-print. This tool helps you create and manage printer configurations.
usage: auto_print_config_generator [-h]
The configuration generator provides an interactive interface to create and manage printer configurations.
python -m auto_print.auto_print_config_generator
Interactive Commands
Once the configuration generator is running, you can use the following interactive commands:
save
ors
: Save the current configurationadd
ora
: Add a new printer sectiondelete
ord
: Delete a printer sectionrepair
orr
: Repair the configuration (fix invalid printer references)show
: Display the current configurationchange
: Change the position of a sectionedit
ore
: Edit a sectionclose
orc
: Close the applicationhelp
orh
: Show help
Print Executor
Auto-print: A document routing application that automatically decides whether to print documents directly or open them with the default application based on filename patterns.
usage: auto_print_execute [-h] file_path
Positional Arguments
- file_path
Path to the file to be processed
The print executor is used to print files based on the configuration.
python -m auto_print.auto_print_execute <file_path>
- Arguments:
file_path
: Path to the file to be printed
Process Flow
When you run the print executor with a file path, it follows this process:
Checks if the file exists
Loads the printer configuration from
%USERPROFILE%\auto-printer\auto-printer-config.json
Extracts the filename from the path
Compares the filename against each configuration section: - If both prefix and suffix match, the file is processed according to that section - If a prefix or suffix is not specified in a section, that part of the check is always considered a match
For the first matching section, the file is: - Printed directly to the specified printer if “print” is true - Opened with the default application if “show” is true - Both printed and shown if both are true
If no matching section is found, an error is logged
Example:
python -m auto_print.auto_print_execute invoice_123.pdf
This will print the file “invoice_123.pdf” to the appropriate printer based on your configuration.
Exit Codes
The print executor returns the following exit codes:
0
: Success-1
: No file to print specified-2
: Too many arguments-3
: File does not exist-4
: Error loading configuration-5
: Ghostscript not installed or other error