99__copyright__ = "2020 Alexander Willner"
1010__credits__ = ["Alexander Willner" ]
1111__license__ = "Apache License 2.0"
12- __version__ = "2.6.2 "
12+ __version__ = "2.6.3 "
1313__maintainer__ = "Alexander Willner"
14141515__status__ = "Development"
2121import webbrowser
2222import argcomplete # type: ignore
2323from things3 .things3 import Things3
24+ from things3 .things3_opml import Things3OPML
2425
2526
2627class Things3CLI ():
2728 """Simple read-only Thing 3 CLI."""
2829
2930 print_json = False
3031 print_csv = False
32+ print_opml = False
33+ anonymize = False
3134 things3 = None
3235
3336 def __init__ (self , database = None ):
@@ -37,6 +40,8 @@ def print_tasks(self, tasks):
3740 """Print a task."""
3841 if self .print_json :
3942 print (json .dumps (tasks ))
43+ elif self .print_opml :
44+ Things3OPML ().print_tasks (tasks )
4045 elif self .print_csv :
4146 fieldnames = ['uuid' , 'title' , 'context' , 'context_uuid' , 'size' ,
4247 'type' , 'due' , 'created' , 'modified' , 'started' ,
@@ -48,7 +53,7 @@ def print_tasks(self, tasks):
4853 else :
4954 for task in tasks :
5055 title = task ['title' ]
51- context = task ['context' ]
56+ context = task ['context' ] if 'context' in task else ''
5257 print (' - ' , title , ' (' , context , ')' )
5358
5459 @classmethod
@@ -88,6 +93,10 @@ def get_parser(cls):
8893 help = 'Shows all tasks' )
8994 subparsers .add_parser ('csv' ,
9095 help = 'Exports tasks as CSV' )
96+ subparsers .add_parser ('areas' ,
97+ help = 'Shows all areas' )
98+ subparsers .add_parser ('opml' ,
99+ help = 'Exports tasks as OPML' )
91100 subparsers .add_parser ('due' ,
92101 help = 'Shows tasks with due dates' )
93102 subparsers .add_parser ('empty' ,
@@ -147,6 +156,14 @@ def get_parser(cls):
147156 action = "store_true" , default = False ,
148157 help = "output as CSV" , dest = "csv" )
149158
159+ parser .add_argument ("-o" , "--opml" ,
160+ action = "store_true" , default = False ,
161+ help = "output as OPML" , dest = "opml" )
162+
163+ parser .add_argument ("-a" , "--anonymize" ,
164+ action = "store_true" , default = False ,
165+ help = "anonymize output" , dest = "anonymize" )
166+
150167 parser .add_argument (
151168 "--version" ,
152169 action = "version" ,
@@ -165,10 +182,15 @@ def main(self, args=None):
165182 command = args .command
166183 self .print_json = args .json
167184 self .print_csv = args .csv
185+ self .print_opml = args .opml
186+ self .anonymize = args .anonymize
187+ self .things3 .anonymize = self .anonymize
168188
169189 if command in self .things3 .functions :
170190 func = self .things3 .functions [command ]
171191 self .print_tasks (func (self .things3 ))
192+ elif command == "opml" :
193+ Things3OPML ().print_all (self .things3 )
172194 elif command == "csv" :
173195 print ("Deprecated: use --csv instead" )
174196 elif command == "feedback" :
0 commit comments