Skip to content

Commit

Permalink
Preview and under same argument .
Browse files Browse the repository at this point in the history
  • Loading branch information
iamaziz committed Sep 19, 2015
1 parent 1a236f7 commit 30e026e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ If 1) you are a terminal addict, and 2) you want to stay up to date with the out

- browse latest feeds by category of your library.

`$ feed -p <CATEGORY>`
`$ feed -t`

- preview the RSS sources stored under `<CATEGORY>` in your library.
- list the topics stored in your library.

`$ feed -t <CATEGORY>`

- list the URLs stored under <category> in your library.

`$ feed -a <RSS-LINK>`

Expand Down Expand Up @@ -81,18 +84,13 @@ Help
$ pip install TermFeed


download and unpack the [zipped folder](https://github.com/iamaziz/TermFeed/archive/master.zip), then:

2) from the source distribution,

download and unpack the [zipped folder](https://github.com/iamaziz/TermFeed/archive/master.zip), then:

$ cd TermFeed
$ python setup.py install

Or
3) Alternatively link the executable `feed.py` from the downloaded folder to some directory in your `PATH`, e.g.

ln -s ~/Downloads/TermFeed/termfeed/feed.py /usr/local/bin/feed

### Uninstall


Expand Down Expand Up @@ -123,3 +121,8 @@ This file is created at the home directory (e.g. `$HOME/.termfeed.db`), delete i
### Author

- Aziz Alto

### changelog:

- Merge listing `urls` and `topics` under same argument.
- Add option to re-build library from command line.
16 changes: 11 additions & 5 deletions termfeed/dbop.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,22 @@ def read(topic):
def browse_links(topic):
if topic in d.keys():
links = d[topic]
print('"{}" contents:'.format(topic))
print('{} resources:'.format(topic))
for link in links:
print('\t{}'.format(link))
else:
print('no category named {}'.format(topic))
print('Available topics: {}'.format(topics()))
print_topics()


def print_topics():
print('available topics: ')
for t in topics():
print('\t{}'.format(t))


def add_link(link, topic='General'):

if topic in d.keys():
if link not in d[topic]:
# to add a new url: copy, mutates, store back
Expand Down Expand Up @@ -81,7 +87,7 @@ def delete_topic(topic):


# if __name__ == '__main__':

# for l in read('News'):
# print(l)

Expand All @@ -90,4 +96,4 @@ def delete_topic(topic):
# add_link('http://rt.com/rss/', 'News')

# for l in read('News'):
# print(l)
# print(l)
24 changes: 11 additions & 13 deletions termfeed/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@
feed
feed <rss-url>
feed -b
feed -p <category>
feed -a <rss-url> [<category>]
feed -d <rss-url>
feed -t
feed -t [<category>]
feed (-h | --help)
feed --version
Options:
List feeds from the default category 'General'.
List feeds from the default category 'General' of your library.
<URL> List feeds from the provided url source.
-b Browse feed by category avaialble in the database file.
-p TOPIC Preview the stored urls of the topic <category>.
-a URL Add new url <rss-url> to database under [<category] (or 'General' otherwise).
-d URL Delete <rss-url> from the database file.
-t See the stored category tags (topics) stored in your library.
-t See the stored categories in your library, or list the URLs stored under <category> in your library.
-h --help Show this screen.
"""
Expand Down Expand Up @@ -211,15 +209,14 @@ def validate_feed(url):

def main():
args = docopt(
__doc__, version="TermFeed 0.0.5 (with pleasure by: Aziz Alto)")
__doc__, version="TermFeed 0.0.7 (with pleasure by: Aziz Alto)")

# parse args
browse = args['-b']
external = args['<rss-url>']
add_link = args['-a']
category = args['<category>']
delete = args['-d']
view = args['-p']
tags = args['-t']

fetch = True
Expand All @@ -231,10 +228,10 @@ def main():
urls = topic_choice(browse)

# if not listing feeds
if add_link or delete or view or category or tags:
if add_link or delete or category or tags:
fetch = False

# updating URLs db
# updating URLs library
if add_link:
url = validate_feed(add_link)
if category:
Expand All @@ -243,14 +240,15 @@ def main():
dbop.add_link(url)

if tags:
for t in dbop.topics():
print(t)
if category:
dbop.browse_links(category)
else:
dbop.print_topics()

if delete:
dbop.remove_link(delete)

if view:
dbop.browse_links(view)


if fetch:
fetch_feeds(urls)
Expand Down

0 comments on commit 30e026e

Please sign in to comment.