uca

package module
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

README

uca-print

Build status GoDoc godocs.io

uca-print is a set of tools to print documents from the command-line.

Installation

$> go install git.sr.ht/~sbinet/uca-print/cmd/uca-print

Examples

$> uca-print -h
Usage: uca-print [options] file1.pdf [file2.odt [...]]

ex:
 $> uca-print ./file1.pdf
 $> uca-print -u username ./file1.pdf ./file2.pdf
 $> uca-print -u username -p s3cr3t ./file1.pdf ./file2.pdf

options:
  -p string
    	password for papercut
  -t duration
    	timeout for sending files to print (default 20s)
  -u string
    	username for papercut

$> uca-print ./f1.pdf ./f2.pdf
uca-print: file: [ERR] "f1.pdf": Disallowed paper size: submission error
uca-print: file: [ OK] "f2.pdf"

$> echo $?
1

Credentials for uca-print can also be stored in $HOME/.config/uca-print/auth.cfg:

$> cat ~/.config/uca-print/auth.cfg
user     my-username
cred-cmd some authentication command # optional.

cred-cmd would typically point at, e.g.:

cred-cmd pass uca.fr/me

uca-print-srv

uca-print also provides a REST-like server that can forward printing requests:

$> go install git.sr.ht/~sbinet/uca-print/cmd/uca-print-srv
$> uca-print-srv -addr :8080 -cert ./cert/server.crt -priv ./cert/server.key

and, in another terminal:

$> curl -X POST \
    -k ## to allow self-signed certificates \
    -u username:s3cr3t \
    --form file='@path-to-file1.pdf' \
    --form file='@path-to-file2.pdf' \
    --form file='@path-to-file3.pdf' \
    https://localhost:8080

Documentation

Overview

Package uca provides tools to send files to print to papercut.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUndefinedQueue = errors.New("printer queue undefined")
	ErrNoQueue        = errors.New("no such printer queue")
	ErrInvalidAuth    = errors.New("invalid authentication")
	ErrSubmission     = errors.New("submission error")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides a means to authenticate with and send files to a PaperCut web-print server.

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient creates a new PaperCut client with the provided options.

By default, the client will try to locate the credentials file named $HOME/.config/uca-print/auth.cfg.

func (*Client) Close

func (cli *Client) Close() (err error)

func (*Client) Printers added in v0.6.0

func (cli *Client) Printers(ctx context.Context) ([]Printer, error)

Printers returns the list of known printer queues.

func (*Client) Send

func (cli *Client) Send(ctx context.Context, fnames []string) ([]Report, error)

Send sends the files to be printed to the web-print PaperCut server and returns back a status report for each of them.

type Option

type Option func(c *Client) error

Option configures a client.

func WithAuth

func WithAuth(usr, pwd string) Option

WithAuth provides the user+password authentication mechanism to a PaperCut web-print server.

func WithQueue added in v0.6.0

func WithQueue(id string) Option

WithQueue specifies which printer queue ID to use.

func WithUser

func WithUser(usr string) Option

WithUser provides the user name to authenticate with a PaperCut web-print server. The user is prompted to provide their password interactively.

type Printer added in v0.6.0

type Printer struct {
	ID   string
	Name string
}

type Report added in v0.2.0

type Report struct {
	File string
	Err  error
}

Report describes the result of a job submission to PaperCut.

Directories

Path Synopsis
cmd
uca-print
Command uca-print sends files to print to PaperCut via the UCA web-print URL.
Command uca-print sends files to print to PaperCut via the UCA web-print URL.
uca-print-ls
Command uca-print-ls lists the available PaperCut printer queues via the UCA web-print URL.
Command uca-print-ls lists the available PaperCut printer queues via the UCA web-print URL.
uca-print-srv
Command uca-print-srv runs a simple REST server that sends print requests to the UCA PaperCut web service.
Command uca-print-srv runs a simple REST server that sends print requests to the UCA PaperCut web service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL