doing 1.0.93 → 2.0.6.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHORS +19 -0
  3. data/CHANGELOG.md +616 -0
  4. data/COMMANDS.md +1181 -0
  5. data/Gemfile +2 -0
  6. data/Gemfile.lock +110 -0
  7. data/LICENSE +23 -0
  8. data/README.md +15 -699
  9. data/Rakefile +79 -0
  10. data/_config.yml +1 -0
  11. data/bin/doing +1055 -494
  12. data/doing.gemspec +34 -0
  13. data/doing.rdoc +1839 -0
  14. data/example_plugin.rb +209 -0
  15. data/generate_completions.sh +5 -0
  16. data/img/doing-colors.jpg +0 -0
  17. data/img/doing-printf-wrap-800.jpg +0 -0
  18. data/img/doing-show-note-formatting-800.jpg +0 -0
  19. data/lib/completion/_doing.zsh +203 -0
  20. data/lib/completion/doing.bash +449 -0
  21. data/lib/completion/doing.fish +329 -0
  22. data/lib/doing/array.rb +8 -0
  23. data/lib/doing/cli_status.rb +70 -0
  24. data/lib/doing/colors.rb +136 -0
  25. data/lib/doing/configuration.rb +312 -0
  26. data/lib/doing/errors.rb +109 -0
  27. data/lib/doing/hash.rb +31 -0
  28. data/lib/doing/hooks.rb +59 -0
  29. data/lib/doing/item.rb +155 -0
  30. data/lib/doing/log_adapter.rb +344 -0
  31. data/lib/doing/markdown_document_listener.rb +174 -0
  32. data/lib/doing/note.rb +59 -0
  33. data/lib/doing/pager.rb +95 -0
  34. data/lib/doing/plugin_manager.rb +208 -0
  35. data/lib/doing/plugins/export/csv_export.rb +48 -0
  36. data/lib/doing/plugins/export/html_export.rb +83 -0
  37. data/lib/doing/plugins/export/json_export.rb +140 -0
  38. data/lib/doing/plugins/export/markdown_export.rb +85 -0
  39. data/lib/doing/plugins/export/taskpaper_export.rb +34 -0
  40. data/lib/doing/plugins/export/template_export.rb +141 -0
  41. data/lib/doing/plugins/import/cal_to_json.scpt +0 -0
  42. data/lib/doing/plugins/import/calendar_import.rb +76 -0
  43. data/lib/doing/plugins/import/doing_import.rb +144 -0
  44. data/lib/doing/plugins/import/timing_import.rb +78 -0
  45. data/lib/doing/string.rb +348 -0
  46. data/lib/doing/symbol.rb +16 -0
  47. data/lib/doing/time.rb +18 -0
  48. data/lib/doing/util.rb +186 -0
  49. data/lib/doing/version.rb +1 -1
  50. data/lib/doing/wwid.rb +1868 -2349
  51. data/lib/doing/wwidfile.rb +117 -0
  52. data/lib/doing.rb +43 -3
  53. data/lib/examples/commands/autotag.rb +63 -0
  54. data/lib/examples/commands/wiki.rb +81 -0
  55. data/lib/examples/plugins/hooks.rb +22 -0
  56. data/lib/examples/plugins/say_export.rb +202 -0
  57. data/lib/examples/plugins/templates/wiki.css +169 -0
  58. data/lib/examples/plugins/templates/wiki.haml +27 -0
  59. data/lib/examples/plugins/templates/wiki_index.haml +18 -0
  60. data/lib/examples/plugins/wiki_export.rb +87 -0
  61. data/lib/templates/doing-markdown.erb +5 -0
  62. data/man/doing.1 +964 -0
  63. data/man/doing.1.html +711 -0
  64. data/man/doing.1.ronn +600 -0
  65. data/package-lock.json +3 -0
  66. data/rdoc_to_mmd.rb +42 -0
  67. data/rdocfixer.rb +13 -0
  68. data/scripts/generate_bash_completions.rb +211 -0
  69. data/scripts/generate_fish_completions.rb +204 -0
  70. data/scripts/generate_zsh_completions.rb +168 -0
  71. metadata +82 -7
  72. data/lib/doing/helpers.rb +0 -191
  73. data/lib/doing/markdown_export.rb +0 -16
@@ -0,0 +1,329 @@
1
+ function __fish_doing_needs_command
2
+ # Figure out if the current invocation already has a command.
3
+
4
+ set -l opts h-help config_file= f-doing_file= n-notes v-version stdout d-debug default x-noauto
5
+ set cmd (commandline -opc)
6
+ set -e cmd[1]
7
+ argparse -s $opts -- $cmd 2>/dev/null
8
+ or return 0
9
+ # These flags function as commands, effectively.
10
+ if set -q argv[1]
11
+ # Also print the command, so this can be used to figure out what it is.
12
+ echo $argv[1]
13
+ return 1
14
+ end
15
+ return 0
16
+ end
17
+
18
+ function __fish_doing_using_command
19
+ set -l cmd (__fish_doing_needs_command)
20
+ test -z "$cmd"
21
+ and return 1
22
+ contains -- $cmd $argv
23
+ and return 0
24
+ end
25
+
26
+ function __fish_doing_complete_sections
27
+ doing sections -c
28
+ end
29
+
30
+ function __fish_doing_complete_views
31
+ doing views -c
32
+ end
33
+
34
+ function __fish_doing_subcommands
35
+ doing help -c
36
+ end
37
+
38
+ function __fish_doing_export_plugins
39
+ doing plugins --type export -c
40
+ end
41
+
42
+ function __fish_doing_import_plugins
43
+ doing plugins --type import -c
44
+ end
45
+
46
+ function __fish_doing_complete_templates
47
+ doing template -c
48
+ end
49
+
50
+ complete -c doing -f
51
+ complete -xc doing -n '__fish_doing_needs_command' -a '(__fish_doing_subcommands)'
52
+
53
+ complete -f -c doing -n '__fish_doing_using_command show' -a '(__fish_doing_complete_sections)'
54
+ complete -f -c doing -n '__fish_doing_using_command view' -a '(__fish_doing_complete_views)'
55
+ complete -f -c doing -n '__fish_doing_using_command template' -a '(__fish_doing_complete_templates)'
56
+ complete -f -c doing -s t -l type -x -n '__fish_doing_using_command import' -a '(__fish_doing_import_plugins)'
57
+
58
+ complete -xc doing -n '__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from (doing help -c)' -a "(doing help -c)"
59
+
60
+ complete -xc doing -n '__fish_doing_needs_command' -a 'add_section' -d Add\ a\ new\ section\ to\ the\ \"doing\"\ file
61
+ complete -xc doing -n '__fish_doing_needs_command' -a 'again resume' -d Repeat\ last\ entry\ as\ new\ entry
62
+ complete -xc doing -n '__fish_doing_needs_command' -a 'archive move' -d Move\ entries\ between\ sections
63
+ complete -xc doing -n '__fish_doing_needs_command' -a 'autotag' -d Autotag\ last\ entry\ or\ filtered\ entries
64
+ complete -xc doing -n '__fish_doing_needs_command' -a 'cancel' -d End\ last\ X\ entries\ with\ no\ time\ tracked
65
+ complete -xc doing -n '__fish_doing_needs_command' -a 'choose' -d Select\ a\ section\ to\ display\ from\ a\ menu
66
+ complete -xc doing -n '__fish_doing_needs_command' -a 'colors' -d List\ available\ color\ variables\ for\ configuration\ templates\ and\ views
67
+ complete -xc doing -n '__fish_doing_needs_command' -a 'config' -d Edit\ the\ configuration\ file\ or\ output\ a\ value\ from\ it
68
+ complete -xc doing -n '__fish_doing_needs_command' -a 'done did' -d Add\ a\ completed\ item\ with\ @done\(date\)
69
+ complete -xc doing -n '__fish_doing_needs_command' -a 'finish' -d Mark\ last\ X\ entries\ as\ @done
70
+ complete -xc doing -n '__fish_doing_needs_command' -a 'grep search' -d Search\ for\ entries
71
+ complete -xc doing -n '__fish_doing_needs_command' -a 'help' -d Shows\ a\ list\ of\ commands\ or\ help\ for\ one\ command
72
+ complete -xc doing -n '__fish_doing_needs_command' -a 'import' -d Import\ entries\ from\ an\ external\ source
73
+ complete -xc doing -n '__fish_doing_needs_command' -a 'last' -d Show\ the\ last\ entry
74
+ complete -xc doing -n '__fish_doing_needs_command' -a 'later' -d Add\ an\ item\ to\ the\ Later\ section
75
+ complete -xc doing -n '__fish_doing_needs_command' -a 'mark flag' -d Mark\ last\ entry\ as\ flagged
76
+ complete -xc doing -n '__fish_doing_needs_command' -a 'meanwhile' -d Finish\ any\ running\ @meanwhile\ tasks\ and\ optionally\ create\ a\ new\ one
77
+ complete -xc doing -n '__fish_doing_needs_command' -a 'note' -d Add\ a\ note\ to\ the\ last\ entry
78
+ complete -xc doing -n '__fish_doing_needs_command' -a 'now next' -d Add\ an\ entry
79
+ complete -xc doing -n '__fish_doing_needs_command' -a 'on' -d List\ entries\ for\ a\ date
80
+ complete -xc doing -n '__fish_doing_needs_command' -a 'open' -d Open\ the\ \"doing\"\ file\ in\ an\ editor
81
+ complete -xc doing -n '__fish_doing_needs_command' -a 'plugins' -d List\ installed\ plugins
82
+ complete -xc doing -n '__fish_doing_needs_command' -a 'recent' -d List\ recent\ entries
83
+ complete -xc doing -n '__fish_doing_needs_command' -a 'reset begin' -d Reset\ the\ start\ time\ of\ an\ entry
84
+ complete -xc doing -n '__fish_doing_needs_command' -a 'rotate' -d Move\ entries\ to\ archive\ file
85
+ complete -xc doing -n '__fish_doing_needs_command' -a 'sections' -d List\ sections
86
+ complete -xc doing -n '__fish_doing_needs_command' -a 'select' -d Display\ an\ interactive\ menu\ to\ perform\ operations
87
+ complete -xc doing -n '__fish_doing_needs_command' -a 'show' -d List\ all\ entries
88
+ complete -xc doing -n '__fish_doing_needs_command' -a 'since' -d List\ entries\ since\ a\ date
89
+ complete -xc doing -n '__fish_doing_needs_command' -a 'tag' -d Add\ tag\(s\)\ to\ last\ entry
90
+ complete -xc doing -n '__fish_doing_needs_command' -a 'template' -d Output\ HTML
91
+ complete -xc doing -n '__fish_doing_needs_command' -a 'test' -d Test\ Stuff
92
+ complete -xc doing -n '__fish_doing_needs_command' -a 'today' -d List\ entries\ from\ today
93
+ complete -xc doing -n '__fish_doing_needs_command' -a 'undo' -d Undo\ the\ last\ change\ to\ the\ doing_file
94
+ complete -xc doing -n '__fish_doing_needs_command' -a 'view' -d Display\ a\ user-created\ view
95
+ complete -xc doing -n '__fish_doing_needs_command' -a 'views' -d List\ available\ custom\ views
96
+ complete -xc doing -n '__fish_doing_needs_command' -a 'wiki' -d Output\ a\ tag\ wiki
97
+ complete -xc doing -n '__fish_doing_needs_command' -a 'yesterday' -d List\ entries\ from\ yesterday
98
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command again resume' -d Boolean\ used\ to\ combine\ multiple\ tags
99
+ complete -c doing -l editor -s e -f -n '__fish_doing_using_command again resume' -d Edit\ duplicated\ entry\ with\ vim\ before\ adding
100
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command again resume' -d Select\ item\ to\ resume\ from\ a\ menu\ of\ matching\ entries
101
+ complete -c doing -l in -f -r -n '__fish_doing_using_command again resume' -d Add\ new\ entry\ to\ section
102
+ complete -c doing -l note -s n -f -r -n '__fish_doing_using_command again resume' -d Note
103
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command again resume' -d Get\ last\ entry\ from\ a\ specific\ section
104
+ complete -c doing -l search -f -r -n '__fish_doing_using_command again resume' -d Repeat\ last\ entry\ matching\ search
105
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command again resume' -d Repeat\ last\ entry\ matching\ tags
106
+ complete -c doing -l before -f -r -n '__fish_doing_using_command archive move' -d Archive\ entries\ older\ than\ date
107
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command archive move' -d Tag\ boolean
108
+ complete -c doing -l keep -s k -f -r -n '__fish_doing_using_command archive move' -d How\ many\ items\ to\ keep
109
+ complete -c doing -l label -f -n '__fish_doing_using_command archive move' -d Label\ moved\ items\ with\ @from\(SECTION_NAME\)
110
+ complete -c doing -l search -f -r -n '__fish_doing_using_command archive move' -d Search\ filter
111
+ complete -c doing -l to -s t -f -r -n '__fish_doing_using_command archive move' -d Move\ entries\ to
112
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command archive move' -d Tag\ filter
113
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command autotag' -d Boolean
114
+ complete -c doing -l count -s c -f -r -n '__fish_doing_using_command autotag' -d How\ many\ recent\ entries\ to\ autotag
115
+ complete -c doing -l force -f -n '__fish_doing_using_command autotag' -d Don\'t\ ask\ permission\ to\ autotag\ all\ entries\ when\ count\ is\ 0
116
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command autotag' -d Select\ item\(s\)\ to\ tag\ from\ a\ menu\ of\ matching\ entries
117
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command autotag' -d Section
118
+ complete -c doing -l search -f -r -n '__fish_doing_using_command autotag' -d Autotag\ entries\ matching\ search\ filter
119
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command autotag' -d Autotag\ the\ last\ X\ entries\ containing\ TAG
120
+ complete -c doing -l unfinished -s u -f -n '__fish_doing_using_command autotag' -d Autotag\ last\ entry
121
+ complete -c doing -l archive -s a -f -n '__fish_doing_using_command cancel' -d Archive\ entries
122
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command cancel' -d Boolean
123
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command cancel' -d Select\ item\(s\)\ to\ cancel\ from\ a\ menu\ of\ matching\ entries
124
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command cancel' -d Section
125
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command cancel' -d Cancel\ the\ last\ X\ entries\ containing\ TAG
126
+ complete -c doing -l unfinished -s u -f -n '__fish_doing_using_command cancel' -d Cancel\ last\ entry
127
+ complete -c doing -F -n '__fish_doing_using_command config'
128
+ complete -c doing -l dump -s d -f -n '__fish_doing_using_command config' -d Show\ a\ config\ key\ value\ based\ on\ arguments
129
+ complete -c doing -l editor -s e -f -r -n '__fish_doing_using_command config' -d Editor\ to\ use
130
+ complete -c doing -l output -s o -f -r -n '__fish_doing_using_command config' -d Format\ for\ --dump
131
+ complete -c doing -l update -s u -f -n '__fish_doing_using_command config' -d Update\ config\ file\ with\ missing\ configuration\ options
132
+ complete -c doing -l archive -s a -f -n '__fish_doing_using_command done did' -d Immediately\ archive\ the\ entry
133
+ complete -c doing -l at -f -r -n '__fish_doing_using_command done did' -d Set\ finish\ date\ to\ specific\ date/time
134
+ complete -c doing -l back -s b -f -r -n '__fish_doing_using_command done did' -d Backdate\ start\ date\ by\ interval\ \[4pm\|20m\|2h\|yesterday\ noon\]
135
+ complete -c doing -l date -f -n '__fish_doing_using_command done did' -d Include\ date
136
+ complete -c doing -l editor -s e -f -n '__fish_doing_using_command done did' -d Edit\ entry\ with\ vim
137
+ complete -c doing -l note -s n -f -r -n '__fish_doing_using_command done did' -d Include\ a\ note
138
+ complete -c doing -l remove -s r -f -n '__fish_doing_using_command done did' -d Remove\ @done\ tag
139
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command done did' -d Section
140
+ complete -c doing -l took -s t -f -r -n '__fish_doing_using_command done did' -d Set\ completion\ date\ to\ start\ date\ plus\ interval
141
+ complete -c doing -l unfinished -s u -f -n '__fish_doing_using_command done did' -d Finish\ last\ entry\ not\ already\ marked\ @done
142
+ complete -c doing -l archive -s a -f -n '__fish_doing_using_command finish' -d Archive\ entries
143
+ complete -c doing -l at -f -r -n '__fish_doing_using_command finish' -d Set\ finish\ date\ to\ specific\ date/time
144
+ complete -c doing -l auto -f -n '__fish_doing_using_command finish' -d Auto-generate\ finish\ dates\ from\ next\ entry\'s\ start\ time
145
+ complete -c doing -l back -s b -f -r -n '__fish_doing_using_command finish' -d Backdate\ completed\ date\ to\ date\ string\ \[4pm\|20m\|2h\|yesterday\ noon\]
146
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command finish' -d Boolean
147
+ complete -c doing -l date -f -n '__fish_doing_using_command finish' -d Include\ date
148
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command finish' -d Select\ item\(s\)\ to\ finish\ from\ a\ menu\ of\ matching\ entries
149
+ complete -c doing -l remove -s r -f -n '__fish_doing_using_command finish' -d Remove\ done\ tag
150
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command finish' -d Section
151
+ complete -c doing -l search -f -r -n '__fish_doing_using_command finish' -d Finish\ the\ last\ X\ entries\ matching\ search\ filter
152
+ complete -c doing -l took -s t -f -r -n '__fish_doing_using_command finish' -d Set\ the\ completed\ date\ to\ the\ start\ date\ plus\ XX\[hmd\]
153
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command finish' -d Finish\ the\ last\ X\ entries\ containing\ TAG
154
+ complete -c doing -l unfinished -s u -f -n '__fish_doing_using_command finish' -d Finish\ last\ entry
155
+ complete -c doing -l after -f -r -n '__fish_doing_using_command grep search' -d Constrain\ search\ to\ entries\ newer\ than\ date
156
+ complete -c doing -l before -f -r -n '__fish_doing_using_command grep search' -d Constrain\ search\ to\ entries\ older\ than\ date
157
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command grep search' -d Display\ an\ interactive\ menu\ of\ results\ to\ perform\ further\ operations
158
+ complete -c doing -l output -s o -f -r -n '__fish_doing_using_command grep search' -d Output\ to\ export\ format
159
+ complete -c doing -l only_timed -f -n '__fish_doing_using_command grep search' -d Only\ show\ items\ with\ recorded\ time\ intervals
160
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command grep search' -d Section
161
+ complete -c doing -l times -s t -f -n '__fish_doing_using_command grep search' -d Show\ time\ intervals\ on\ @done\ tasks
162
+ complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command grep search' -d Sort\ tags\ by
163
+ complete -c doing -l totals -f -n '__fish_doing_using_command grep search' -d Show\ intervals\ with\ totals\ at\ the\ end\ of\ output
164
+ complete -c doing -F -n '__fish_doing_using_command import'
165
+ complete -c doing -l after -f -r -n '__fish_doing_using_command import' -d Import\ entries\ newer\ than\ date
166
+ complete -c doing -l autotag -f -n '__fish_doing_using_command import' -d Autotag\ entries
167
+ complete -c doing -l before -f -r -n '__fish_doing_using_command import' -d Import\ entries\ older\ than\ date
168
+ complete -c doing -l from -s f -f -r -n '__fish_doing_using_command import' -d Date\ range\ to\ import
169
+ complete -c doing -l only_timed -f -n '__fish_doing_using_command import' -d Only\ import\ items\ with\ recorded\ time\ intervals
170
+ complete -c doing -l overlap -f -n '__fish_doing_using_command import' -d Allow\ entries\ that\ overlap\ existing\ times
171
+ complete -c doing -l prefix -f -r -n '__fish_doing_using_command import' -d Prefix\ entries\ with
172
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command import' -d Target\ section
173
+ complete -c doing -l search -f -r -n '__fish_doing_using_command import' -d Only\ import\ items\ matching\ search
174
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command import' -d Tag\ all\ imported\ entries
175
+ complete -c doing -l type -f -r -n '__fish_doing_using_command import' -d Import\ type
176
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command last' -d Tag\ boolean
177
+ complete -c doing -l editor -s e -f -n '__fish_doing_using_command last' -d Edit\ entry\ with\ vim
178
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command last' -d Specify\ a\ section
179
+ complete -c doing -l search -f -r -n '__fish_doing_using_command last' -d Search\ filter
180
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command last' -d Tag\ filter
181
+ complete -c doing -l back -s b -f -r -n '__fish_doing_using_command later' -d Backdate\ start\ time\ to\ date\ string\ \[4pm\|20m\|2h\|yesterday\ noon\]
182
+ complete -c doing -l editor -s e -f -n '__fish_doing_using_command later' -d Edit\ entry\ with\ vim
183
+ complete -c doing -l note -s n -f -r -n '__fish_doing_using_command later' -d Note
184
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command mark flag' -d Boolean
185
+ complete -c doing -l count -s c -f -r -n '__fish_doing_using_command mark flag' -d How\ many\ recent\ entries\ to\ tag
186
+ complete -c doing -l date -s d -f -n '__fish_doing_using_command mark flag' -d Include\ current\ date/time\ with\ tag
187
+ complete -c doing -l force -f -n '__fish_doing_using_command mark flag' -d Don\'t\ ask\ permission\ to\ flag\ all\ entries\ when\ count\ is\ 0
188
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command mark flag' -d Select\ item\(s\)\ to\ flag\ from\ a\ menu\ of\ matching\ entries
189
+ complete -c doing -l remove -s r -f -n '__fish_doing_using_command mark flag' -d Remove\ flag
190
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command mark flag' -d Section
191
+ complete -c doing -l search -f -r -n '__fish_doing_using_command mark flag' -d Flag\ the\ last\ entry\ matching\ search\ filter
192
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command mark flag' -d Flag\ the\ last\ entry\ containing\ TAG
193
+ complete -c doing -l unfinished -s u -f -n '__fish_doing_using_command mark flag' -d Flag\ last\ entry
194
+ complete -c doing -l archive -s a -f -n '__fish_doing_using_command meanwhile' -d Archive\ previous\ @meanwhile\ entry
195
+ complete -c doing -l back -s b -f -r -n '__fish_doing_using_command meanwhile' -d Backdate\ start\ date\ for\ new\ entry\ to\ date\ string\ \[4pm\|20m\|2h\|yesterday\ noon\]
196
+ complete -c doing -l editor -s e -f -n '__fish_doing_using_command meanwhile' -d Edit\ entry\ with\ vim
197
+ complete -c doing -l note -s n -f -r -n '__fish_doing_using_command meanwhile' -d Note
198
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command meanwhile' -d Section
199
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command note' -d Boolean
200
+ complete -c doing -l editor -s e -f -n '__fish_doing_using_command note' -d Edit\ entry\ with\ vim
201
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command note' -d Select\ item\ for\ new\ note\ from\ a\ menu\ of\ matching\ entries
202
+ complete -c doing -l remove -s r -f -n '__fish_doing_using_command note' -d Replace/Remove\ last\ entry\'s\ note
203
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command note' -d Section
204
+ complete -c doing -l search -f -r -n '__fish_doing_using_command note' -d Add/remove\ note\ from\ last\ entry\ matching\ search\ filter
205
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command note' -d Add/remove\ note\ from\ last\ entry\ matching\ tag
206
+ complete -c doing -l back -s b -f -r -n '__fish_doing_using_command now next' -d Backdate\ start\ time\ \[4pm\|20m\|2h\|yesterday\ noon\]
207
+ complete -c doing -l editor -s e -f -n '__fish_doing_using_command now next' -d Edit\ entry\ with\ vim
208
+ complete -c doing -l finish_last -s f -f -n '__fish_doing_using_command now next' -d Timed\ entry
209
+ complete -c doing -l note -s n -f -r -n '__fish_doing_using_command now next' -d Include\ a\ note
210
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command now next' -d Section
211
+ complete -c doing -l output -s o -f -r -n '__fish_doing_using_command on' -d Output\ to\ export\ format
212
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command on' -d Section
213
+ complete -c doing -l times -s t -f -n '__fish_doing_using_command on' -d Show\ time\ intervals\ on\ @done\ tasks
214
+ complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command on' -d Sort\ tags\ by
215
+ complete -c doing -l totals -f -n '__fish_doing_using_command on' -d Show\ time\ totals\ at\ the\ end\ of\ output
216
+ complete -c doing -l app -s a -f -r -n '__fish_doing_using_command open' -d Open\ with\ app\ name
217
+ complete -c doing -l bundle_id -s b -f -r -n '__fish_doing_using_command open' -d Open\ with\ app\ bundle\ id
218
+ complete -c doing -l column -s c -f -n '__fish_doing_using_command plugins' -d List\ in\ single\ column\ for\ completion
219
+ complete -c doing -l type -s t -f -r -n '__fish_doing_using_command plugins' -d List\ plugins\ of\ type
220
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command recent' -d Select\ from\ a\ menu\ of\ matching\ entries\ to\ perform\ additional\ operations
221
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command recent' -d Section
222
+ complete -c doing -l times -s t -f -n '__fish_doing_using_command recent' -d Show\ time\ intervals\ on\ @done\ tasks
223
+ complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command recent' -d Sort\ tags\ by
224
+ complete -c doing -l totals -f -n '__fish_doing_using_command recent' -d Show\ intervals\ with\ totals\ at\ the\ end\ of\ output
225
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command reset begin' -d Boolean
226
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command reset begin' -d Select\ from\ a\ menu\ of\ matching\ entries
227
+ complete -c doing -l resume -s r -f -n '__fish_doing_using_command reset begin' -d Resume\ entry
228
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command reset begin' -d Set\ the\ start\ date\ of\ an\ item\ to\ now
229
+ complete -c doing -l search -f -r -n '__fish_doing_using_command reset begin' -d Reset\ last\ entry\ matching\ search\ filter
230
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command reset begin' -d Reset\ last\ entry\ matching\ tag
231
+ complete -c doing -l before -f -r -n '__fish_doing_using_command rotate' -d Rotate\ entries\ older\ than\ date
232
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command rotate' -d Tag\ boolean
233
+ complete -c doing -l keep -s k -f -r -n '__fish_doing_using_command rotate' -d How\ many\ items\ to\ keep\ in\ each\ section
234
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command rotate' -d Section\ to\ rotate
235
+ complete -c doing -l search -f -r -n '__fish_doing_using_command rotate' -d Search\ filter
236
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command rotate' -d Tag\ filter
237
+ complete -c doing -l column -s c -f -n '__fish_doing_using_command sections' -d List\ in\ single\ column
238
+ complete -c doing -l archive -s a -f -n '__fish_doing_using_command select' -d Archive\ selected\ items
239
+ complete -c doing -l resume -f -n '__fish_doing_using_command select' -d Copy\ selection\ as\ a\ new\ entry\ with\ current\ time\ and\ no\ @done\ tag
240
+ complete -c doing -l cancel -s c -f -n '__fish_doing_using_command select' -d Cancel\ selected\ items
241
+ complete -c doing -l delete -s d -f -n '__fish_doing_using_command select' -d Delete\ selected\ items
242
+ complete -c doing -l editor -s e -f -n '__fish_doing_using_command select' -d Edit\ selected\ item\(s\)
243
+ complete -c doing -l finish -s f -f -n '__fish_doing_using_command select' -d Add\ @done\ with\ current\ time\ to\ selected\ item\(s\)
244
+ complete -c doing -l flag -f -n '__fish_doing_using_command select' -d Add\ flag\ to\ selected\ item\(s\)
245
+ complete -c doing -l force -f -n '__fish_doing_using_command select' -d Perform\ action\ without\ confirmation
246
+ complete -c doing -l move -s m -f -r -n '__fish_doing_using_command select' -d Move\ selected\ items\ to\ section
247
+ complete -c doing -l menu -f -n '__fish_doing_using_command select' -d Use\ --no-menu\ to\ skip\ the\ interactive\ menu
248
+ complete -c doing -l output -s o -f -r -n '__fish_doing_using_command select' -d Output\ entries\ to\ format
249
+ complete -c doing -l search -f -r -n '__fish_doing_using_command select' -d Initial\ search\ query\ for\ filtering
250
+ complete -c doing -l remove -s r -f -n '__fish_doing_using_command select' -d Reverse\ -c
251
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command select' -d Select\ from\ a\ specific\ section
252
+ complete -c doing -l save_to -f -r -n '__fish_doing_using_command select' -d Save\ selected\ entries\ to\ file\ using\ --output\ format
253
+ complete -c doing -l tag -s t -f -r -n '__fish_doing_using_command select' -d Tag\ selected\ entries
254
+ complete -c doing -l age -s a -f -r -n '__fish_doing_using_command show' -d Age
255
+ complete -c doing -l after -f -r -n '__fish_doing_using_command show' -d View\ entries\ newer\ than\ date
256
+ complete -c doing -l bool -s b -f -r -n '__fish_doing_using_command show' -d Tag\ boolean
257
+ complete -c doing -l before -f -r -n '__fish_doing_using_command show' -d View\ entries\ older\ than\ date
258
+ complete -c doing -l count -s c -f -r -n '__fish_doing_using_command show' -d Max\ count\ to\ show
259
+ complete -c doing -l from -s f -f -r -n '__fish_doing_using_command show' -d Date\ range\ to\ show
260
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command show' -d Select\ from\ a\ menu\ of\ matching\ entries\ to\ perform\ additional\ operations
261
+ complete -c doing -l output -s o -f -r -n '__fish_doing_using_command show' -d Output\ to\ export\ format
262
+ complete -c doing -l only_timed -f -n '__fish_doing_using_command show' -d Only\ show\ items\ with\ recorded\ time\ intervals
263
+ complete -c doing -l sort -s s -f -r -n '__fish_doing_using_command show' -d Sort\ order
264
+ complete -c doing -l search -f -r -n '__fish_doing_using_command show' -d Search\ filter
265
+ complete -c doing -l times -s t -f -n '__fish_doing_using_command show' -d Show\ time\ intervals\ on\ @done\ tasks
266
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command show' -d Tag\ filter
267
+ complete -c doing -l tag_order -f -r -n '__fish_doing_using_command show' -d Tag\ sort\ direction
268
+ complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command show' -d Sort\ tags\ by
269
+ complete -c doing -l totals -f -n '__fish_doing_using_command show' -d Show\ intervals\ with\ totals\ at\ the\ end\ of\ output
270
+ complete -c doing -l output -s o -f -r -n '__fish_doing_using_command since' -d Output\ to\ export\ format
271
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command since' -d Section
272
+ complete -c doing -l times -s t -f -n '__fish_doing_using_command since' -d Show\ time\ intervals\ on\ @done\ tasks
273
+ complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command since' -d Sort\ tags\ by
274
+ complete -c doing -l totals -f -n '__fish_doing_using_command since' -d Show\ time\ totals\ at\ the\ end\ of\ output
275
+ complete -c doing -l autotag -s a -f -n '__fish_doing_using_command tag' -d Autotag\ entries\ based\ on\ autotag\ configuration\ in\ \~/
276
+ complete -c doing -l bool -f -r -n '__fish_doing_using_command tag' -d Boolean
277
+ complete -c doing -l count -s c -f -r -n '__fish_doing_using_command tag' -d How\ many\ recent\ entries\ to\ tag
278
+ complete -c doing -l date -s d -f -n '__fish_doing_using_command tag' -d Include\ current\ date/time\ with\ tag
279
+ complete -c doing -l force -f -n '__fish_doing_using_command tag' -d Don\'t\ ask\ permission\ to\ tag\ all\ entries\ when\ count\ is\ 0
280
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command tag' -d Select\ item\(s\)\ to\ tag\ from\ a\ menu\ of\ matching\ entries
281
+ complete -c doing -l remove -s r -f -n '__fish_doing_using_command tag' -d Remove\ given\ tag\(s\)
282
+ complete -c doing -l regex -f -n '__fish_doing_using_command tag' -d Interpret\ tag\ string\ as\ regular\ expression
283
+ complete -c doing -l rename -f -r -n '__fish_doing_using_command tag' -d Replace\ existing\ tag\ with\ tag\ argument
284
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command tag' -d Section
285
+ complete -c doing -l search -f -r -n '__fish_doing_using_command tag' -d Tag\ entries\ matching\ search\ filter
286
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command tag' -d Tag\ the\ last\ X\ entries\ containing\ TAG
287
+ complete -c doing -l unfinished -s u -f -n '__fish_doing_using_command tag' -d Tag\ last\ entry
288
+ complete -c doing -l list -s l -f -n '__fish_doing_using_command template' -d List\ all\ available\ templates
289
+ complete -c doing -l after -f -r -n '__fish_doing_using_command today' -d View\ entries\ after\ specified\ time
290
+ complete -c doing -l before -f -r -n '__fish_doing_using_command today' -d View\ entries\ before\ specified\ time
291
+ complete -c doing -l output -s o -f -r -n '__fish_doing_using_command today' -d Output\ to\ export\ format
292
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command today' -d Specify\ a\ section
293
+ complete -c doing -l times -s t -f -n '__fish_doing_using_command today' -d Show\ time\ intervals\ on\ @done\ tasks
294
+ complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command today' -d Sort\ tags\ by
295
+ complete -c doing -l totals -f -n '__fish_doing_using_command today' -d Show\ time\ totals\ at\ the\ end\ of\ output
296
+ complete -c doing -l file -s f -f -r -n '__fish_doing_using_command undo' -d Specify\ alternate\ doing\ file
297
+ complete -c doing -l after -f -r -n '__fish_doing_using_command view' -d View\ entries\ newer\ than\ date
298
+ complete -c doing -l bool -s b -f -r -n '__fish_doing_using_command view' -d Tag\ boolean
299
+ complete -c doing -l before -f -r -n '__fish_doing_using_command view' -d View\ entries\ older\ than\ date
300
+ complete -c doing -l count -s c -f -r -n '__fish_doing_using_command view' -d Count\ to\ display
301
+ complete -c doing -l color -f -n '__fish_doing_using_command view' -d Include\ colors\ in\ output
302
+ complete -c doing -l interactive -s i -f -n '__fish_doing_using_command view' -d Select\ from\ a\ menu\ of\ matching\ entries\ to\ perform\ additional\ operations
303
+ complete -c doing -l output -s o -f -r -n '__fish_doing_using_command view' -d Output\ to\ export\ format
304
+ complete -c doing -l only_timed -f -n '__fish_doing_using_command view' -d Only\ show\ items\ with\ recorded\ time\ intervals
305
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command view' -d Section
306
+ complete -c doing -l search -f -r -n '__fish_doing_using_command view' -d Search\ filter
307
+ complete -c doing -l times -s t -f -n '__fish_doing_using_command view' -d Show\ time\ intervals\ on\ @done\ tasks
308
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command view' -d Tag\ filter
309
+ complete -c doing -l tag_order -f -r -n '__fish_doing_using_command view' -d Tag\ sort\ direction
310
+ complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command view' -d Sort\ tags\ by
311
+ complete -c doing -l totals -f -n '__fish_doing_using_command view' -d Show\ intervals\ with\ totals\ at\ the\ end\ of\ output
312
+ complete -c doing -l column -s c -f -n '__fish_doing_using_command views' -d List\ in\ single\ column
313
+ complete -c doing -l after -f -r -n '__fish_doing_using_command wiki' -d Include\ entries\ newer\ than\ date
314
+ complete -c doing -l bool -s b -f -r -n '__fish_doing_using_command wiki' -d Tag\ boolean
315
+ complete -c doing -l before -f -r -n '__fish_doing_using_command wiki' -d Include\ entries\ older\ than\ date
316
+ complete -c doing -l from -s f -f -r -n '__fish_doing_using_command wiki' -d Date\ range\ to\ include
317
+ complete -c doing -l only_timed -f -n '__fish_doing_using_command wiki' -d Only\ show\ items\ with\ recorded\ time\ intervals
318
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command wiki' -d Section\ to\ rotate
319
+ complete -c doing -l search -f -r -n '__fish_doing_using_command wiki' -d Search\ filter
320
+ complete -c doing -l tag -f -r -n '__fish_doing_using_command wiki' -d Tag\ filter
321
+ complete -c doing -l after -f -r -n '__fish_doing_using_command yesterday' -d View\ entries\ after\ specified\ time
322
+ complete -c doing -l before -f -r -n '__fish_doing_using_command yesterday' -d View\ entries\ before\ specified\ time
323
+ complete -c doing -l output -s o -f -r -n '__fish_doing_using_command yesterday' -d Output\ to\ export\ format
324
+ complete -c doing -l section -s s -f -r -n '__fish_doing_using_command yesterday' -d Specify\ a\ section
325
+ complete -c doing -l times -s t -f -n '__fish_doing_using_command yesterday' -d Show\ time\ intervals\ on\ @done\ tasks
326
+ complete -c doing -l tag_order -f -r -n '__fish_doing_using_command yesterday' -d Tag\ sort\ direction
327
+ complete -c doing -l tag_sort -f -r -n '__fish_doing_using_command yesterday' -d Sort\ tags\ by
328
+ complete -c doing -l totals -f -n '__fish_doing_using_command yesterday' -d Show\ time\ totals\ at\ the\ end\ of\ output
329
+ complete -f -c doing -s o -l output -x -n '__fish_doing_using_command config grep search on select show since today view yesterday' -a '(__fish_doing_export_plugins)'
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Doing
4
+ ##
5
+ ## @brief Array helpers
6
+ ##
7
+ class ::Array end
8
+ end
@@ -0,0 +1,70 @@
1
+ module Status
2
+ def cols
3
+ @cols ||= `tput cols`.strip.to_i
4
+ end
5
+
6
+ def progress(msg, idx, total, tail = [])
7
+ status_width = format("> %s [%#{total.to_s.length}d/%d]: ", msg, 0, total).length
8
+ max_width = cols - status_width
9
+ if tail.is_a? Array
10
+ tail.shift while tail.join(', ').length + 3 > max_width
11
+ tail = tail.join(', ')
12
+ end
13
+ tail.ltrunc!(max_width)
14
+ $stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['boldgreen']}%s #{esc['white']}[#{esc['boldwhite']}%#{@commands.count.to_s.length}d#{esc['boldblack']}/#{esc['boldyellow']}%d#{esc['white']}]: #{esc['boldcyan']}%s#{esc['default']}\r", msg, idx, total, tail)
15
+ end
16
+
17
+ def status(msg, reset: true)
18
+ $stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['whiteboard']}%s#{esc['default']}%s", msg, reset ? "\r" : "\n")
19
+ end
20
+
21
+ def clear
22
+ $stderr.print format("\r#{esc['kill']}")
23
+ end
24
+
25
+ def esc
26
+ e = {}
27
+ e['kill'] = "\033[2K"
28
+ e['reset'] = "\033[A\033[2K"
29
+ e['black'] = "\033[0;0;30m"
30
+ e['red'] = "\033[0;0;31m"
31
+ e['green'] = "\033[0;0;32m"
32
+ e['yellow'] = "\033[0;0;33m"
33
+ e['blue'] = "\033[0;0;34m"
34
+ e['magenta'] = "\033[0;0;35m"
35
+ e['cyan'] = "\033[0;0;36m"
36
+ e['white'] = "\033[0;0;37m"
37
+ e['bgblack'] = "\033[40m"
38
+ e['bgred'] = "\033[41m"
39
+ e['bggreen'] = "\033[42m"
40
+ e['bgyellow'] = "\033[43m"
41
+ e['bgblue'] = "\033[44m"
42
+ e['bgmagenta'] = "\033[45m"
43
+ e['bgcyan'] = "\033[46m"
44
+ e['bgwhite'] = "\033[47m"
45
+ e['boldblack'] = "\033[1;30m"
46
+ e['boldred'] = "\033[1;31m"
47
+ e['boldgreen'] = "\033[0;1;32m"
48
+ e['boldyellow'] = "\033[0;1;33m"
49
+ e['boldblue'] = "\033[0;1;34m"
50
+ e['boldmagenta'] = "\033[0;1;35m"
51
+ e['boldcyan'] = "\033[0;1;36m"
52
+ e['boldwhite'] = "\033[0;1;37m"
53
+ e['boldbgblack'] = "\033[1;40m"
54
+ e['boldbgred'] = "\033[1;41m"
55
+ e['boldbggreen'] = "\033[1;42m"
56
+ e['boldbgyellow'] = "\033[1;43m"
57
+ e['boldbgblue'] = "\033[1;44m"
58
+ e['boldbgmagenta'] = "\033[1;45m"
59
+ e['boldbgcyan'] = "\033[1;46m"
60
+ e['boldbgwhite'] = "\033[1;47m"
61
+ e['softpurple'] = "\033[0;35;40m"
62
+ e['hotpants'] = "\033[7;34;40m"
63
+ e['knightrider'] = "\033[7;30;40m"
64
+ e['flamingo'] = "\033[7;31;47m"
65
+ e['yeller'] = "\033[1;37;43m"
66
+ e['whiteboard'] = "\033[1;30;47m"
67
+ e['default'] = "\033[0;39m"
68
+ e
69
+ end
70
+ end
@@ -0,0 +1,136 @@
1
+ # Cribbed from <https://github.com/flori/term-ansicolor>
2
+ module Doing
3
+ module Color
4
+
5
+ # :stopdoc:
6
+ ATTRIBUTES = [
7
+ [ :clear , 0 ], # String#clear is already used to empty string in Ruby 1.9
8
+ [ :reset , 0 ], # synonym for :clear
9
+ [ :bold , 1 ],
10
+ [ :dark , 2 ],
11
+ [ :italic , 3 ], # not widely implemented
12
+ [ :underline , 4 ],
13
+ [ :underscore , 4 ], # synonym for :underline
14
+ [ :blink , 5 ],
15
+ [ :rapid_blink , 6 ], # not widely implemented
16
+ [ :negative , 7 ], # no reverse because of String#reverse
17
+ [ :concealed , 8 ],
18
+ [ :strikethrough , 9 ], # not widely implemented
19
+ [ :black , 30 ],
20
+ [ :red , 31 ],
21
+ [ :green , 32 ],
22
+ [ :yellow , 33 ],
23
+ [ :blue , 34 ],
24
+ [ :magenta , 35 ],
25
+ [ :cyan , 36 ],
26
+ [ :white , 37 ],
27
+ [ :bgblack , 40 ],
28
+ [ :bgred , 41 ],
29
+ [ :bggreen , 42 ],
30
+ [ :bgyellow , 43 ],
31
+ [ :bgblue , 44 ],
32
+ [ :bgmagenta , 45 ],
33
+ [ :bgcyan , 46 ],
34
+ [ :bgwhite , 47 ],
35
+ [ :boldblack , 90 ], # High intensity, aixterm (works in OS X)
36
+ [ :boldred , 91 ],
37
+ [ :boldgreen , 92 ],
38
+ [ :boldyellow , 93 ],
39
+ [ :boldblue , 94 ],
40
+ [ :boldmagenta , 95 ],
41
+ [ :boldcyan , 96 ],
42
+ [ :boldwhite , 97 ],
43
+ [ :boldbgblack , 100 ], # High intensity background, aixterm (works in OS X)
44
+ [ :boldbgred , 101 ],
45
+ [ :boldbggreen , 102 ],
46
+ [ :boldbgyellow , 103 ],
47
+ [ :boldbgblue , 104 ],
48
+ [ :boldbgmagenta , 105 ],
49
+ [ :boldbgcyan , 106 ],
50
+ [ :boldbgwhite , 107 ],
51
+ [ :softpurple , '0;35;40'],
52
+ [ :hotpants , '7;34;40'],
53
+ [ :knightrider , '7;30;40'],
54
+ [ :flamingo , '7;31;47'],
55
+ [ :yeller , '1;37;43'],
56
+ [ :whiteboard , '1;30;47'],
57
+ [ :default , '0;39' ]
58
+ ]
59
+
60
+ ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
61
+ # :startdoc:
62
+
63
+ # Returns true if Doing::Color supports the +feature+.
64
+ #
65
+ # The feature :clear, that is mixing the clear color attribute into String,
66
+ # is only supported on ruby implementations, that do *not* already
67
+ # implement the String#clear method. It's better to use the reset color
68
+ # attribute instead.
69
+ def support?(feature)
70
+ case feature
71
+ when :clear
72
+ !String.instance_methods(false).map(&:to_sym).include?(:clear)
73
+ end
74
+ end
75
+ # Returns true, if the coloring function of this module
76
+ # is switched on, false otherwise.
77
+ def self.coloring?
78
+ @coloring
79
+ end
80
+
81
+ # Turns the coloring on or off globally, so you can easily do
82
+ # this for example:
83
+ # Doing::Color::coloring = STDOUT.isatty
84
+ def self.coloring=(val)
85
+ @coloring = val
86
+ end
87
+ self.coloring = true
88
+
89
+ ATTRIBUTES.each do |c, v|
90
+ eval <<-EOT
91
+ def #{c}(string = nil)
92
+ result = ''
93
+ result << "\e[#{v}m" if Doing::Color.coloring?
94
+ if block_given?
95
+ result << yield
96
+ elsif string.respond_to?(:to_str)
97
+ result << string.to_str
98
+ elsif respond_to?(:to_str)
99
+ result << to_str
100
+ else
101
+ return result #only switch on
102
+ end
103
+ result << "\e[0m" if Doing::Color.coloring?
104
+ result
105
+ end
106
+ EOT
107
+ end
108
+
109
+ # Regular expression that is used to scan for ANSI-sequences while
110
+ # uncoloring strings.
111
+ COLORED_REGEXP = /\e\[(?:(?:[349]|10)[0-7]|[0-9])?m/
112
+
113
+ # Returns an uncolored version of the string, that is all
114
+ # ANSI-sequences are stripped from the string.
115
+ def uncolor(string = nil) # :yields:
116
+ if block_given?
117
+ yield.to_str.gsub(COLORED_REGEXP, '')
118
+ elsif string.respond_to?(:to_str)
119
+ string.to_str.gsub(COLORED_REGEXP, '')
120
+ elsif respond_to?(:to_str)
121
+ to_str.gsub(COLORED_REGEXP, '')
122
+ else
123
+ ''
124
+ end
125
+ end
126
+
127
+ module_function
128
+
129
+ # Returns an array of all Doing::Color attributes as symbols.
130
+ def attributes
131
+ ATTRIBUTE_NAMES
132
+ end
133
+ extend self
134
+ end
135
+ end
136
+