Code Monkey home page Code Monkey logo

paperless-cli's Introduction

paperless-cli

license Build Status

badge Stargazers over time

Table of Contents

Description

A CLI tool written in Go to interface with a Paperless instance.

Installation and usage

Prerequisites

You should have a working Go environment and have $GOPATH/bin in your $PATH.

Precompiled binary

You can get a precompiled binary from the releases page (soon).

Self-compiled binary

To download source, compile, and install, run:

$ go get -u github.com/stgarf/paperless-cli
$ $GOPATH/src/github.com/stgarf/paperless-cli/build.sh

The source code will be located in $GOPATH/src/github.com/stgarf/paperless-cli.

A newly compiled binary will be in $GOPATH/src/github.com/stgarf/paperless-cli/bin/

You can place the binary in you $PATH for easy usage. e.g.

$ cp $GOPATH/src/github.com/stgarf/paperless-cli/bin/paperless-cli $GOPATH/bin

$ which paperless-cli should return the path to the newly installed binary.

Usage

Check paperless-cli version

$ paperless-cli version
paperless-cli v0.6.0 built on 2019-03-10T16:28:33Z from git:c8dd2e7-clean (master) by user@chrx

Setting up a config

You can set up a basic YAML-based configuration to be read by placing it in $HOME/.paperless-cli.yaml.

A base config can be autogenerated with paperless-cli config create.

Here's an example configuration:

# A basic paperless-cli configuration file.

# The hostname of the Paperless instance.
hostname: localhost
# Connect via HTTP or HTTPS.
use_https: false
# Port the Paperless instance is listening on.
port: 8000
# Path to the API root.
root: /api
# Username to auth to Paperless instance.
username: myUsername
# Username to auth to Paperless instance.
password: mYpa$$w0rd.is.h0p3fully.s3cur3!!1

Development

Prerequisites

You should have a working Go environment and have $GOPATH/bin in your $PATH.

Get the code

To download the source code, run:

$ go get -du github.com/stgarf/paperless-cli

The source code will be located in $GOPATH/src/github.com/stgarf/paperless-cli.

Running the tests

$ go test

Really though, there are none and need to be written.

Built With

  • cobra - A Commander for modern Go CLI interactions
  • logrus - Structured, pluggable logging for Go
  • gjson - Get JSON values quickly - JSON Parser for Go
  • viper - Go configuration with fangs
  • go-fqdn - Simple wrapper around net and os golang standard libraries providing Fully Qualified Domain Name of the machine
  • go-homedir - Go library for detecting and expanding the user's home directory without cgo
  • govvv - "go build" wrapper to add version info to Golang applications

Contributing

Please read CONTRIBUTING.md for details on the code of conduct, and the process for submitting pull requests to the project.

Versioning

We use SemVer for versioning, roughly. For the versions available, see the tags on this repository.

Authors

  • Steve Garf - Initial CLI work - stgarf
  • Zibby Mofrad - Document Download option - zibby

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache License - see the LICENSE file for details.

Acknowledgments

  • Daniel Quinn for starting Paperless and the awesome community of people maintaining Paperless
  • Seth Junot for rubber duck debugging - xSetech
  • Hat tip to anyone whose code was imported!

paperless-cli's People

Contributors

calinou avatar dependabot[bot] avatar stgarf avatar zibby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

paperless-cli's Issues

some errors while installing

Describe the bug

When running $GOPATH/src/github.com/stgarf/paperless-cli/build.sh this

Need govvv, building and installing..cannot find package "github.com/ahmetb/govvv" in any of:
    /usr/local/go/src/github.com/ahmetb/govvv (from $GOROOT)
    /home/ludde/go/src/github.com/ahmetb/govvv (from $GOPATH)

and this

Need gox, building and installing..cannot find package "github.com/mitchellh/gox" in any of:
    /usr/local/go/src/github.com/mitchellh/gox (from $GOROOT)
    /home/ludde/go/src/github.com/mitchellh/gox (from $GOPATH)

happened.

I solved it with

go get -v -u github.com/ahmetb/govvv github.com/mitchellh/gox

Next error i got when running the build script was this

Building..failed to collect values: failed to get commit: git: error="exit status 128" stderr=fatal: inte ett git-arkiv (eller någon av föräldrakatalogerna): .git
failed to collect values: failed to get commit: git: error="exit status 128" stderr=fatal: inte ett git-arkiv (eller någon av föräldrakatalogerna): .git
Number of parallel builds: 3

. Build complete.

which is due to the use of relative paths.

I solved it with

cd $(readlink -f $0 | xargs dirname)

at the beginning of the build script, and

cd - 1>/dev/null

at the end.

Desktop (please complete the following information):

  • OS: Debian 9 Stretch
  • Go version: go1.15.3 linux/amd64

May I also suggest writing

ln -s $GOPATH/src/github.com/stgarf/paperless-cli/bin/paperless-cli.<OS>.<Arch> $GOPATH/bin/paperless-cli

in README.md instead of using cp.

Improve the docstrings for paperless-cli go documentation

Describe the bug
Improve the docstrings for paperless-cli go documentation when viewing
https://godoc.org/github.com/stgarf/paperless-cli

To Reproduce
Steps to reproduce the behavior:

  1. Visit 'https://godoc.org/github.com/stgarf/paperless-cli' and view documentation
  2. ...
  3. PROFIT!!!

Expected behavior
Clear and concise descriptions of the paperless-cli code.

Screenshots or Stacktrace
N/A

Desktop (please complete the following information):

  • OS: N/A
  • Go version: N/A
  • paperless-cli version: v0.6.2

Additional context
N/A

Latest commit to gjson removed Unmarshal

Trying to create a docker container to use with my Paperless ecosystem

Is your feature request related to a problem? Please describe.
Error getting paperless-cli package

running go get -u github.com/stgarf/paperless-cli

output

src/github.com/stgarf/paperless-cli/paperless/correspondent.go:49:3: undefined: gjson.Unmarshal
src/github.com/stgarf/paperless-cli/paperless/correspondent.go:71:3: undefined: gjson.Unmarshal
src/github.com/stgarf/paperless-cli/paperless/document.go:67:3: undefined: gjson.Unmarshal
src/github.com/stgarf/paperless-cli/paperless/document.go:102:3: undefined: gjson.Unmarshal
src/github.com/stgarf/paperless-cli/paperless/tag.go:112:3: undefined: gjson.Unmarshal
src/github.com/stgarf/paperless-cli/paperless/tag.go:134:3: undefined: gjson.Unmarshal

I checked gson and found out that

The Gjson commit (d10932a) removed Unmarshal function.

some detail from commit to gjson.go (removed code)
...
// Unmarshal loads the JSON data into the value pointed to by v.
//
// This function works almost identically to json.Unmarshal except that
// gjson.Unmarshal will automatically attempt to convert JSON values to any Go
// type. For example, the JSON string "100" or the JSON number 100 can be
// equally assigned to Go string, int, byte, uint64, etc. This rule applies to
// all types.
//
// Deprecated: Use encoder/json.Unmarshal instead
func Unmarshal(data []byte, v interface{}) error {
...

Thanks

I'd like to be able to edit a {tag,correspondent,document}

Is your feature request related to a problem? Please describe.
I'd like to be able to edit the information related to {tag,correspondent,document} such as name, title, slug, match, matching algorithm, tag, etc.

Describe the solution you'd like
Something like
paperless-cli tags edit [id]
paperless-cli correspondents edit [id]
paperless-cli documents edit [id]

Add Travis-CI for CI/CD

Is your feature request related to a problem? Please describe.
Add Travis-CI for CI/CD

Describe the solution you'd like
Add Travis-CI for CI and to push builds back to GitHub.

Describe alternatives you've considered
I haven't thought of others but maybe GitLab.

Additional context
n/a

Document List is serial and slow for large document sets

Describe the bug
If you run a paperless-cli documents list on a large Paperless instance this will cause a serial lookup of the correspondent and each tag on that document because of what the Paperless API returns -- a link to the tag/correspondent and not it's name. This lookup should be optimized.

To Reproduce
Steps to reproduce the behavior:

  1. paperless-cli documents list on a large paperless instance
  2. You'll wait 2-3m for a response in the experience of my dataset.

Expected behavior
Implement some optimization so that this is completed faster.

Screenshots
n/a

Desktop (please complete the following information):

  • Version: 0.6.1

I'd like to download the PDF(s) of a document(s)

Is your feature request related to a problem? Please describe.
I'd like to be able to download the PDF(s) of a particular document or set of documents.

Describe the solution you'd like
Something like paperless-cli documents {fetch,get,download} [document ids]

I'd like to upload the PDF(s) of (a) document(s)

Similar to #7 except I'd like to be able to upload a document with the bare minimum required fields. Flags/args for extra optional fields are a bonus for first MVP.

It's similar to #16 except it's likely a post request with a few required arguments. I'll poke around the Paperless API if I decide to start looking at this.

Show tag colors (paperless-ng)

Is your feature request related to a problem? Please describe.
I like to easily recognize assigned tags etc. of documents to understand it's classification faster.

Describe the solution you'd like
Show CLI with ANSI colorcodes that represent the colors of tags. This could be possible at least for paperless-ng API

Use XDG config directory instead of home directory

Describe the bug
paperless-cli currently clutters the home directory by placing the configuration file directly in ~/.paperless-cli.yaml

To Reproduce
Steps to reproduce the behavior:

  1. just run it

Expected behavior
use $XDG_CONFIG_HOME/paperless-cli/config.yaml (e.g.)

Desktop (please complete the following information):

  • OS: linux
  • Go version:
  • paperless-cli version:

Additional context
https://wiki.archlinux.org/index.php/XDG_Base_Directory
for crossplatform support, you could use https://github.com/shibukawa/configdir
there is a longer discussion [1] about integrating support into golang directly

[1] golang/go#29960

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.