Skip to content

Commit

Permalink
Merge pull request #12 from ccremer/readme
Browse files Browse the repository at this point in the history
Update readme
  • Loading branch information
ccremer authored Dec 27, 2022
2 parents 04081d5 + c0e0a97 commit 3d9c9d0
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 5 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,61 @@
# paperless-cli

CLI tool to interact with paperless-ngx remote API

## Subcommands

- `upload`: Uploads local document(s) to Paperless instance
- `consume`: Consumes a local directory and uploads each file to Paperless instance. The files will be deleted once uploaded.

## Installation

Go:
`go install github.com/ccremer/paperless-cli@latest`

Docker:
`docker run ghcr.io/ccremer/paperless-cli:latest`

Binary:
```bash
wget https://github.com/ccremer/paperless-cli/releases/latest/download/paperless-cli_linux_amd64
chmod +x paperless-cli_linux_amd64
sudo mv paperless-cli_linux_amd64 /usr/local/bin/paperless-cli
```

Deb:
```bash
wget https://github.com/ccremer/paperless-cli/releases/latest/download/paperless-cli_linux_amd64.deb
sudo dpkg -i paperless-cli_linux_amd64.deb
rm paperless-cli_linux_amd64.deb
```

RPM:
```bash
wget https://github.com/ccremer/paperless-cli/releases/latest/download/paperless-cli_linux_amd64.rpm
sudo rpm -i paperless-cli_linux_amd64.rpm
rm paperless-cli_linux_amd64.rpm
```

## Systemd Service

The `consume` subcommand is a long-running process that is best run as a daemon.
The Deb/RPM packages come with a SystemD unit file.

Enable SystemD `consume` service:
```bash
sudo ${EDITOR:-nano} /etc/default/paperless-cli
sudo systemctl enable paperless-consume
sudo systemctl start paperless-consume
```

## Why does this exist?

I didn't any other projects or means to consume a directory but _uploads_ the documents via API.
In my case, I can't configure the scanner to upload to the consume dir as prepared by paperless-already, so I created a tool that also watches a directory, but uploads them to Paperless instead.

Other projects that I've found:

- https://github.com/stgarf/paperless-cli (archived, doesn't upload or consume)

## Development

Expand Down
6 changes: 3 additions & 3 deletions consume_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ type ConsumeCommand struct {
func newConsumeCommand() *ConsumeCommand {
c := &ConsumeCommand{}
c.Command = cli.Command{
Name: "consume",
Description: "Consumes a local directory and uploads each file to Paperless instance. The files will be deleted once uploaded.",
Action: actions(LogMetadata, c.Action),
Name: "consume",
Usage: "Consumes a local directory and uploads each file to Paperless instance. The files will be deleted once uploaded.",
Action: actions(LogMetadata, c.Action),

Flags: []cli.Flag{
newURLFlag(&c.PaperlessURL),
Expand Down
2 changes: 2 additions & 0 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ func newConsumeDirFlag(dest *string) *cli.StringFlag {
func checkEmptyString(flagName string) func(*cli.Context, string) error {
return func(ctx *cli.Context, s string) error {
if s == "" {
subcommands := ctx.Command.Subcommands
ctx.Command.Subcommands = nil // required to print usage of subcommand
_ = cli.ShowCommandHelp(ctx, ctx.Command.Name)
ctx.Command.Subcommands = subcommands
return fmt.Errorf(`Required flag %q not set`, flagName)
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions upload_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ type UploadCommand struct {
func newUploadCommand() *UploadCommand {
c := &UploadCommand{}
c.Command = cli.Command{
Name: "upload",
Description: "Uploads local document(s) to Paperless instance",
Name: "upload",
Usage: "Uploads local document(s) to Paperless instance",
Before: func(ctx *cli.Context) error {
if ctx.NArg() == 0 {
ctx.Command.Subcommands = nil // required to print usage of subcommand
Expand Down

0 comments on commit 3d9c9d0

Please sign in to comment.