rakanalh / pocket-cli Goto Github PK
View Code? Open in Web Editor NEWA terminal application for Pocket
License: MIT License
A terminal application for Pocket
License: MIT License
It'd be great if in .pocket-config there was an optional line about what "browser" to open it with - that way I could have pocket-cli open in lynx or elinks (or even pipe it to pandoc and then less) while not having to change my default browser.
I have just installed this in termux for android, and somehow on the last configuration step browser window isn't opened. Generally it would be good to provide a link to copy & visit manually to obtain an access token, as a fallback to such cases.
It's a bit confusing with apps that insists on using one or two dashes for --help
and --version
, when the rest of the commands don't use dashes.
I suggest that -h
, --help
, and help
be made equivalent (and the same pattern for version
). this will make the interface more consistent.
When trying to fetch articles for the first time after configuring:
$ pocket-cli fetch
Loading articles \Traceback (most recent call last):
File "/usr/bin/pocket-cli", line 11, in <module>
sys.exit(main())
File "/usr/lib/python3.5/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3.5/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python3.5/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3.5/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3.5/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.5/site-packages/pocket_cli/cli.py", line 177, in fetch
pocket_app.fetch_articles(True)
File "/usr/lib/python3.5/site-packages/pocket_cli/app.py", line 129, in fetch_articles
articles_index.extend(self._get_articles_index(articles))
File "/usr/lib/python3.5/site-packages/pocket_cli/app.py", line 162, in _get_articles_index
word_count = int(article['word_count'])
KeyError: 'word_count'
Pocket-CLI doesn't seem to have a --version
option, but it's the latest from PyPI.
There's no "tags" flag for the read or random commands.
Something like:
$ pocket-cli random --tags work
to grab a random article from all those tagged 'work'
I'm seeing items I've already archived showing back up as a result of pocket-cli random
- I'm not sure if this is an issue with the cli client or with pocket itself and I'm not sure how to go about testing it.
Being that the expected results are supposed to be random, it's not really easily reproducible! :)
When configuring Pocket-CLI I was asked about (1) how to sort articles and (2) my reading speed. However, I was given no clues to which options were available for sorting and I have no idea how many words per minute I am able to read. So I entered some rubbish for question 1 (and found out that the options were id
and reading_time
) and off-handedly guessed at 300 wpm for question 2.
It would be helpful if new users were presented with (1) possible sorting fields, and (2) some examples of reading speed, e.g. “50 (slow), 200 (medium), 1000 (fast)” (I'm just grabbing some numbers out of thin air here).
after i have installed pocket-cli and i try to pocket-cli configure
Please provide your consumer key:
Please provide your consumer key: 5XXXX-c5XXXXXXXXXXXXXXXXXXXXXXX
Please provide your preferred sort field
Available options are [id, reading_time]
default: [reading_time]: reading_time
Please specify your reading speed in words per minute
You can use this URL to estimate your reading time
http://www.readingsoft.com/
default: [180]: 1000
Traceback (most recent call last):
File "/usr/bin/pocket-cli", line 11, in <module>
load_entry_point('pocket-cli==0.1.4', 'console_scripts', 'pocket-cli')()
File "/usr/lib/python2.7/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/pocket_cli/cli.py", line 51, in configure
request_token = pocket_app.get_request_token(consumer_key)
File "/usr/lib/python2.7/site-packages/pocket_cli/app.py", line 48, in get_request_token
consumer_key, self.REDIRECT_URL
TypeError: get_request_token() takes exactly 2 arguments (3 given)
Somehow the first line of .pocket-index - url,reading_time,id,word_count,title - disappeared from the file, and the program kept crashing. An error catch to discover if the first line is what we expect (and perhaps even write it to the file if it's not there) would be helpful (and saved me a couple of hours!)
The command pocket-cli configure
by default leaves ~/.pocket-config
file world readable:
$ ls -l ~/.pocket-config
-rw-r--r-- 1 kseistrup kseistrup 166 Feb 20 11:29 /home/kseistrup/.pocket-config
Since this file contains sensitive information (consumer_key
and access_token
) the file should be made readable only by the user (umask 0077) or at most by the user and their group (umask 0027) by setting thwe umask before creating the file.
E.g.,
diff --git a/pocket_cli/config.py b/pocket_cli/config.py
index 08ad61a..e572b2b 100644
--- a/pocket_cli/config.py
+++ b/pocket_cli/config.py
@@ -29,7 +29,9 @@ class Configs:
self._config_parser.set(self._section_name, name, str(value))
def write(self):
+ old_umask = os.umask(int('0077', 8))
self._config_parser.write(open(self._get_file_path(), 'w'))
+ _ = os.umask(old_umask)
def _get_file_path(self):
return '{}/.pocket-config'.format(os.path.expanduser('~'))
The reason for using the cryptic int('0077', 8)
is that octal 0077 is presented like that in Python 2, while Python 3 uses 0o077 (which isn't recognized by Python 2).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.