Giter Club home page Giter Club logo

gocket's Introduction

gocket

Logo of Gocket

travis CLI Go Report Card Codacy Badge Hits-of-Code License Tweet

A simple CLI (or TUI) for Pocket.

  • Read your Pocket goodies from your comfy shell.
  • Archive or delete multiple entries easily.
  • Use a TUI or pipe the pages' URLs (or titles) to any CLI you want.
  • Search through your Pocket list.
  • Works on Linux, macOS (not tested), and Windows (not tested).

screenshot of gocket tui

Gocket is in early version. Its interface might change. See the CHANGELOG

Installation

General

You can simply grab the latest binary file and download the version you need, depending on your OS.

Linux script

If you use a Linux-based OS, here's a simple way to download gocket and move it to /usr/local/bin. You can then call it wherever you want.

curl -L https://raw.githubusercontent.com/Phantas0s/gocket/master/install/linux.sh | bash

Manual installation

  • You need the last version of Golang installed.
  • You need to clone this repository and build the binary in the root directory with the command go build.

Authorization

You need to authorize gocket to access your Pocket account. It's very easy:

Steps

  1. Go to Gocket apps and create an application
  2. Authorize the application to add, modify, and retrieve if you want to use the full set of gocket's feature
  3. You need to pass the consumer key to gocket each time you use it (-k option) or you can use a config file:
    1. Create the file $XDG_CONFIG_HOME/gocket/config.yml
    2. Create an entry with key as index and the consumer key as value, for example key: 1234-5a6b7c
    3. Your config can be a YAML, TOML, or JSON file
  4. The first time you use pocket, you'll need to confirm your authorization. A webpage will open automatically in your favorite browser to do so
  5. Enjoy!

XDG Home Directory

Running gocket list without any consumer key will display an error message indicating where to create the config file.

The value of $XDG_CONFIG_HOME depends of your OS. Here are the defaults (if you didn't modify it):

  • Unix systems: ~/.config
  • macOS: ~/Library/Application Support
  • Windows: %LOCALAPPDATA%

Commands

Use the option -h for each command to output the help.

List

  • gocket list: list your Pocket pages.
  • gocket list archive: list the archives.

The options for these two commands are almost identical. Here are the difference:

  • Use -a with gocket list to bulk add every listed entry to the archive (with confirmation).
  • Use -a with gocket list archive to bulk add every listed archive to the unread list (with confirmation).

Adding New Pages

  • gocket add <URLs...>: Add the URLs <URLs....> to pocket. You can add multiple URLs separated with spaces.

This command will read the standard input stream (stdin) if no argument is given. For example:

echo "https://thevaluable.dev" | gocket add

If you want to display a message when each URL is successfully added, use the option verbose (-v).

Usage

If you choose to use the TUI, you can select a page and open it with your favorite browser using the ENTER key.

Description Command
Output every page's URLs gocket list
Display every page's URLs in a TUI gocket list --tui
Output the last 5 pages' URLs added gocket list -c 5
Display pages in a TUI and don't ask confirmation for any operation gocket list -c 5 --tui --noconfirm
Filter for type 'video' ('article' or 'image' possible too) gocket list -f "video"
Search for "youtube" in titles and URLs gocket list -s "golang"
Open the last page added with Firefox gocket list -c 1 | xargs firefox
Open the last page added with Lynx gocket list -c 1 | lynx -
Open the oldest page added with Firefox gocket list -c 1 -o "oldest" | xargs firefox
Open the last 5 pages added with Firefox and archive them gocket list -c 5 -a --noconfirm | xargs firefox
Open the last page added with Firefox and delete it gocket list -c 1 -d --noconfirm | xargs firefox
Print only the pages' titles gocket list -c 10 -t | sed 'n;d'

As a bonus for Linux users (might work on macOS too), you can use fzf to fuzzy search the page you want and open it with Firefox:

gocket list -c 5 -t | sed 'N;s#\n# /// #' | fzf | awk -F ' /// ' '{print $2}' | xargs firefox

Option, Configuration, and Environment Variables

You can provide the different options to gocket using:

  1. Command-line options (i.e gocket list --tui)
  2. Environment variables (i.e export GOCKET_TUI=true)
  3. Configuration file (i.e tui: true in $XDG_CONFIG_HOME/gocket/config.yaml|json|toml)

If these options are defined multiple times, the priorities follow the order above (from higher priority to lower).

The names of the environment variables need to be uppercase and prefixed with GOCKET_. Every hyphen - in the option's name needs to be replaced with an underscore _.

TUI Keystrokes

Navigation

 โ†‘ or k: up
 โ†“ or j: down
 PgUp or CTRL+u: One screen up
 PgDn or CTRL+d: One screen down
 Home or g: Top of the list
 End or G: Bottom of the list

Action

 ENTER: Open the selected page with your favorite browser
 d: Delete Pocket entry
 a: Add (if list archive) or archive (if list unread)

Sponsorship

Consider sponsoring my work if you want to see new, fresh, and crunchy little CLIs (and TUIs) all over your system.

Building Your Mouseless Development Environment

Switching between a keyboard and mouse costs cognitive energy. My book will help you set up a Linux-based development environment that keeps your hands on your keyboard. Take the brain power you've been using to juggle input devices and focus it where it belongs: on the things you create.

You'll learn how to write your own installation scripts too!

Acknowledgements

  • Thanks to the project go-pocket, it gave me the basic data structures and other ideas.
  • Thanks to MariaLetta for the awesome and beautiful Gopher pack! I used it for my logo on top.
  • Thanks to Lukasz Adam for his free and amazing illustrations I use basically everywhere.

Licence

Apache Licence 2.0

gocket's People

Contributors

dorneanu avatar phantas0s 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

Watchers

 avatar  avatar  avatar  avatar  avatar

gocket's Issues

Trying to authenticate under Termux Android

I downloaded latest 0.2.4 arm 64 version and unpacked under Termux on Android phone. Then I tried to authenticate with my key and -k option, which generated me the error:

panic: Post "https://getpocket.com/v3/oauth/request": dial tcp: lookup getpocket.com on [::1]:53: read udp [::1]:42101->[::1]:53: read: connection refused

goroutine 1 [running]:
github.com/Phantas0s/gocket/internal/platform.Auth(0x7ff5ea6707, 0x1e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/hypnos/workspace/gocket/internal/platform/auth.go:54 +0x4c0
github.com/Phantas0s/gocket/internal.CreatePocket(0x7ff5ea6707, 0x1e, 0x40001ebc88)
	/home/hypnos/workspace/gocket/internal/pocket.go:23 +0x30
github.com/Phantas0s/gocket/cmd.runList()
	/home/hypnos/workspace/gocket/cmd/list.go:47 +0x48
github.com/Phantas0s/gocket/cmd.listCmd.func1(0x40000d5080, 0x40000da9c0, 0x0, 0x4)
	/home/hypnos/workspace/gocket/cmd/list.go:21 +0x20
github.com/spf13/cobra.(*Command).execute(0x40000d5080, 0x40000da980, 0x4, 0x4, 0x40000d5080, 0x40000da980)
	/home/hypnos/workspace/go/pkg/mod/github.com/spf13/[email protected]/command.go:854 +0x1d0
github.com/spf13/cobra.(*Command).ExecuteC(0x40000d4dc0, 0x8196e0, 0x4d0df4, 0x3)
	/home/hypnos/workspace/go/pkg/mod/github.com/spf13/[email protected]/command.go:958 +0x268
github.com/spf13/cobra.(*Command).Execute(...)
	/home/hypnos/workspace/go/pkg/mod/github.com/spf13/[email protected]/command.go:895
github.com/Phantas0s/gocket/cmd.Execute()
	/home/hypnos/workspace/gocket/cmd/root.go:53 +0x12c
main.main()
	/home/hypnos/workspace/gocket/main.go:8 +0x20

Is there something I can do to make it work?

Regards,
Piotr

Wrong URL opened

I had the top article highlighted and typed ENTER and the bottom URL opened.

gocket-wrong-url-11-13-38

Authorization issue with Pocket on Windows

Hi there,

Thanks for making this tool, this is great! I always like seeing new TUI clients for online services.

Issue

I'm trying to run gocket from Powershell in Windows Terminal on Windows 10. I've built the binary from source and followed the authorization instructions in the README and saved the application key in C:\Users\<user>\AppData\Local\gocket\config.yml.

However, when I run gocket list, a new webpage opens to authorize the application with Pocket for the first time, and the application doesn't authorize.

image

There isn't any more specific information than this, so I'm not sure where the issue might be.

Troubleshooting

Gocket does run properly within Windows Subsystem for Linux

Using the Windows Subsystem for Linux, I've built the binary again in my Ubuntu subsystem and copied the config.yml file from C:\Users\<user>\AppData\Local\gocket\config.yml. to /home/<user>/.config/gocket/config.yml. When I run gocket list, the app authorizes correctly and I can see my saved list.

So I think I've made the application key correctly and stored it in the right format.

Console error message

On Windows, when the authorization step fails, there are a couple errors listed in the Firefox console that may help with diagnosing the issue.

image

On Microsoft Edge (Chromium version), the console error is similar but slightly different.

image

Machine information

Just in case this will help, here is some information about my system.

Variable Value
Operating system Windows 10 Pro version 20H2 x86_64
Kernel Kernel: 10.0.19042
Browser Firefox 87.0, Edge 89.0.774.63

Thanks

continuous url fetching

url fetching process is continuous without stop, when i issued the following command in terminal.

gocket list -c 20 -t | sed 'N;s#\n# /// #' | fzf | awk -F ' /// ' '{print $2}' | xargs w3m 
or
gocket list -c 20 -t | sed 'N;s#\n# /// #' | fzf | awk -F ' /// ' '{print $2}' | xargs firefox

gocket list -c 20 is fetchng urls list without any problem.

I request you to give browser option in configuration file ( to set terminal browsers like w3m ) as interface of terminal browser goes well with gocket tui and change over to view mode is quick.

w3m with readerview gives distraction free reading experience.

Add version subcommand/info

I just reinstalled the latest to confirm a bugfix and there doesn't yet seem to be a way to verify which version I'm running.

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.