new command : list edit
This commit is contained in:
parent
fcf8605af9
commit
fd5da8761d
|
@ -74,6 +74,7 @@ To avoid using unstable or too recent libraries, the rule of thumb is that a lib
|
||||||
provide a better and slightly more secure experience when using the default
|
provide a better and slightly more secure experience when using the default
|
||||||
TOFU certificate validation mode and is highly recommended (apt-get install python3-cryptography).
|
TOFU certificate validation mode and is highly recommended (apt-get install python3-cryptography).
|
||||||
* [Python magic](https://github.com/ahupp/python-magic/) is useful to determine the MIME type of cached object. If not present, the file extension will be used but some capsules provide wrong extension or no extension at all. (apt-get install python3-magic)
|
* [Python magic](https://github.com/ahupp/python-magic/) is useful to determine the MIME type of cached object. If not present, the file extension will be used but some capsules provide wrong extension or no extension at all. (apt-get install python3-magic)
|
||||||
|
* [Python editor](https://github.com/fmoo/python-editor) is used to edit your lists with "list edit". (apt-get install python3-editor)
|
||||||
* [Xsel](http://www.vergenet.net/~conrad/software/xsel/) allows to `go` to the URL copied in the clipboard without having to paste it (both X and traditional clipboards are supported). Also needed to use the `copy` command. (apt-get install xsel)
|
* [Xsel](http://www.vergenet.net/~conrad/software/xsel/) allows to `go` to the URL copied in the clipboard without having to paste it (both X and traditional clipboards are supported). Also needed to use the `copy` command. (apt-get install xsel)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
29
offpunk.py
29
offpunk.py
|
@ -42,6 +42,12 @@ import urllib.parse
|
||||||
import uuid
|
import uuid
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
|
try:
|
||||||
|
import editor
|
||||||
|
_HAS_EDITOR = True
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
_HAS_EDITOR = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ansiwrap as textwrap
|
import ansiwrap as textwrap
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
|
@ -2118,7 +2124,7 @@ Bookmarks are stored using the 'add' command."""
|
||||||
|
|
||||||
def list_create(self,list,title=None):
|
def list_create(self,list,title=None):
|
||||||
list_path = self.list_path(list)
|
list_path = self.list_path(list)
|
||||||
if list in ["create"]:
|
if list in ["create","edit"]:
|
||||||
print("%s is not allowed as a name for a list"%list)
|
print("%s is not allowed as a name for a list"%list)
|
||||||
elif not list_path:
|
elif not list_path:
|
||||||
listdir = os.path.join(_DATA_DIR,"lists")
|
listdir = os.path.join(_DATA_DIR,"lists")
|
||||||
|
@ -2170,10 +2176,11 @@ If current page was not in a list, this command is similar to `add LIST`."""
|
||||||
|
|
||||||
def do_list(self,arg):
|
def do_list(self,arg):
|
||||||
"""Manage list of bookmarked pages.
|
"""Manage list of bookmarked pages.
|
||||||
- list : display the list of available lists
|
- list : display available lists
|
||||||
- list $LIST : display pages in list $LIST
|
- list $LIST : display pages in $LIST
|
||||||
- list create $NEWLIST : create a list
|
- list create $NEWLIST : create a new list
|
||||||
See alse :
|
- list edit $LIST : edit the list
|
||||||
|
See also :
|
||||||
- add $LIST (to add current page to list)
|
- add $LIST (to add current page to list)
|
||||||
- move $LIST (to add current page to list while removing from all others)"""
|
- move $LIST (to add current page to list while removing from all others)"""
|
||||||
listdir = os.path.join(_DATA_DIR,"lists")
|
listdir = os.path.join(_DATA_DIR,"lists")
|
||||||
|
@ -2201,6 +2208,18 @@ See alse :
|
||||||
self.list_create(args[1].lower())
|
self.list_create(args[1].lower())
|
||||||
else:
|
else:
|
||||||
print("A name is required to create a new list. Use `list create NAME`")
|
print("A name is required to create a new list. Use `list create NAME`")
|
||||||
|
elif args[0] == "edit":
|
||||||
|
if not _HAS_EDITOR:
|
||||||
|
print("Please install python-editor to edit you lists")
|
||||||
|
elif len(args) > 1:
|
||||||
|
if args[1] in self.list_lists():
|
||||||
|
path = os.path.join(listdir,args[1]+".gmi")
|
||||||
|
editor.edit(path)
|
||||||
|
else:
|
||||||
|
print("A valid list name is required to edit a list")
|
||||||
|
else:
|
||||||
|
print("A valid list name is required to edit a list")
|
||||||
|
|
||||||
elif len(args) == 1:
|
elif len(args) == 1:
|
||||||
self.list_show(args[0].lower())
|
self.list_show(args[0].lower())
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user