nin 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/bin/nin +3 -2
- data/lib/nin/command.rb +11 -5
- data/lib/nin/integration/synchronizer.rb +5 -2
- data/lib/nin/presenters/item_presenter.rb +5 -5
- data/lib/nin/todo.rb +22 -5
- data/lib/nin/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39f9e7a10bb0b9d4433ec8e048f0f98a86b69c446df00b87f60011ed51656be2
|
4
|
+
data.tar.gz: f531e76fab7c0dee8883f8f05bf4f5b4f2ce8ecd8322203dac43bb4ecb6dd72b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36dd67aa3390451a0c127c3fcfa8c053ba8976ce7c24da2c4a822c243dfdb6b5b70a2639e222e0b6378ea4f4bd3e1696a0ebb98025808ec7ff0bf95274852c27
|
7
|
+
data.tar.gz: 56953c2a4da2d7eab114f35fc195a0e9415958737b1dc8133edf658cf1cbe9c4f26ba1f903223ca861457b9da7e3230a2f715c1faace7a4e7a4e2de23e988995
|
data/README.md
CHANGED
@@ -41,12 +41,13 @@ COMMANDS:
|
|
41
41
|
e | edit id desc Edit a todo. Prepend due date by a @. Prepend each tag by a \#
|
42
42
|
p | prioritize id step Prioritize a todo by either a positive or negative step within its date group
|
43
43
|
c | complete id(s) Un/complete todo(s)
|
44
|
-
ac | archive id(s)
|
44
|
+
ac | archive id(s)|c Un/archive todo(s) or pass `c` to archive all completed items
|
45
45
|
d | delete id(s) Delete todo(s)
|
46
46
|
gc | garbage Delete all archived todos. Resets item ids as a side effect
|
47
47
|
s | analyze Analyze tasks and print statistics
|
48
48
|
i | repl Open nin in REPL mode
|
49
49
|
o | open Open todo file in $EDITOR
|
50
|
+
v | version Print current version of nin
|
50
51
|
```
|
51
52
|
|
52
53
|
- Print the usage instructions by calling `nin` without commands or arguments
|
@@ -80,6 +81,7 @@ COMMANDS:
|
|
80
81
|
For Todoist integration, two environment variables must be set:
|
81
82
|
- `NIN_INTEGRATION_CLIENT=todoist`
|
82
83
|
- `NIN_INTEGRATION_CLIENT_TOKEN=token`. Token can be found in your [integration settings page](https://todoist.com/prefs/integrations)
|
84
|
+
- `NIN_INTEGRATION_TIMEOUT=interval_in_seconds`. A timeout interval for when the synchronization times out. Defaults to 60 seconds
|
83
85
|
|
84
86
|
## Development
|
85
87
|
|
@@ -102,8 +104,8 @@ my phone and I needed something more readable.
|
|
102
104
|
|
103
105
|
## Contribution
|
104
106
|
|
105
|
-
Contributions are welcome. If you
|
106
|
-
open an issue or send a pull request.
|
107
|
+
Contributions are welcome. If you find a bug or want to add a new feature,
|
108
|
+
please open an issue or send a pull request.
|
107
109
|
|
108
110
|
## License
|
109
111
|
|
data/bin/nin
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
require_relative '../lib/nin'
|
4
4
|
|
5
5
|
config = {
|
6
|
-
|
7
|
-
|
6
|
+
integration_client: ENV['NIN_INTEGRATION_CLIENT'],
|
7
|
+
integration_client_token: ENV['NIN_INTEGRATION_CLIENT_TOKEN'],
|
8
|
+
integration_timeout_interval: ENV['NIN_INTEGRATION_TIMEOUT']
|
8
9
|
}
|
9
10
|
|
10
11
|
begin
|
data/lib/nin/command.rb
CHANGED
@@ -37,6 +37,8 @@ module Nin
|
|
37
37
|
run_interactive_mode
|
38
38
|
when 'o', 'open'
|
39
39
|
system("`echo $EDITOR` #{@todo.store.file}")
|
40
|
+
when 'v', 'version'
|
41
|
+
puts "nin #{Nin::VERSION}"
|
40
42
|
else
|
41
43
|
puts "NAME:\n\tnin - a simple, full-featured command line todo app"
|
42
44
|
puts "\nUSAGE:\n\tnin COMMAND [arguments...]"
|
@@ -46,12 +48,13 @@ module Nin
|
|
46
48
|
puts "\te | edit id desc Edit a todo. Prepend due date by a @. Prepend each tag by a \\#"
|
47
49
|
puts "\tp | prioritize id step Prioritize a todo by either a positive or negative step within its date group"
|
48
50
|
puts "\tc | complete id(s) Un/complete todo(s)"
|
49
|
-
puts "\tac | archive id(s)
|
51
|
+
puts "\tac | archive id(s)|c Un/archive todo(s) or pass `c` to archive all completed items"
|
50
52
|
puts "\td | delete id(s) Delete todo(s)"
|
51
53
|
puts "\tgc | garbage Delete all archived todos. Resets item ids as a side effect"
|
52
54
|
puts "\ts | analyze Analyze tasks and print statistics"
|
53
55
|
puts "\ti | repl Open nin in REPL mode"
|
54
56
|
puts "\to | open Open todo file in $EDITOR"
|
57
|
+
puts "\tv | version Print current version of nin"
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
@@ -60,25 +63,28 @@ module Nin
|
|
60
63
|
def collect_config
|
61
64
|
config = { store: YamlStore.new }
|
62
65
|
|
63
|
-
_client_name = @config.fetch(:
|
64
|
-
_client_credentials = @config.fetch(:
|
66
|
+
_client_name = @config.fetch(:integration_client, nil)
|
67
|
+
_client_credentials = @config.fetch(:integration_client_token, nil)
|
68
|
+
_timeout_interval = @config.fetch(:integration_timeout_interval, 60)
|
65
69
|
if _client_name && _client_credentials
|
66
70
|
_client_klass = Object.const_get("Nin::Integration::#{_client_name.capitalize}::Client")
|
67
71
|
_synchronizer_klass = Object.const_get("Nin::Integration::Synchronizer::#{_client_name.capitalize}")
|
68
72
|
|
69
|
-
config[:integration_syncrhonizer] = _synchronizer_klass.new(_client_klass.new(_client_credentials))
|
73
|
+
config[:integration_syncrhonizer] = _synchronizer_klass.new(_client_klass.new(_client_credentials), _timeout_interval)
|
70
74
|
end
|
71
75
|
|
72
76
|
config
|
73
77
|
end
|
74
78
|
|
75
79
|
def collect_options
|
76
|
-
options = { archived: false, local: false }
|
80
|
+
options = { archived: false, local: false, completed_only: false }
|
77
81
|
|
78
82
|
if @command == 'l' && @args[0] == 'a'
|
79
83
|
options[:archived] = true
|
80
84
|
elsif @command == 'l' && @args[0] == 'l'
|
81
85
|
options[:local] = true
|
86
|
+
elsif @command == 'ac' && @args[0] == 'c'
|
87
|
+
options[:completed_only] = true
|
82
88
|
end
|
83
89
|
|
84
90
|
options
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module Nin
|
2
2
|
module Integration
|
3
3
|
class Synchronizer
|
4
|
-
|
5
|
-
|
4
|
+
attr_reader :timeout_interval
|
5
|
+
|
6
|
+
def initialize(client, timeout_interval = nil)
|
7
|
+
@client = client
|
8
|
+
@timeout_interval = timeout_interval
|
6
9
|
end
|
7
10
|
end
|
8
11
|
end
|
@@ -2,7 +2,7 @@ module Nin
|
|
2
2
|
module Presenter
|
3
3
|
class ItemPresenter < ::SimpleDelegator
|
4
4
|
def call(options = {})
|
5
|
-
_id, _completed, _date, _desc, _tags = id,
|
5
|
+
_id, _completed, _date, _desc, _tags = id, decorate_completed, decorate_date, decorate_desc, decorate_tags
|
6
6
|
|
7
7
|
separating_spaces = options.fetch(:separating_spaces, 2)
|
8
8
|
id_spaces = options.fetch(:longest_id, 1) + separating_spaces
|
@@ -15,7 +15,7 @@ module Nin
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
18
|
+
def decorate_desc
|
19
19
|
if self.archived?
|
20
20
|
self.desc.yellow
|
21
21
|
elsif self.completed?
|
@@ -25,7 +25,7 @@ module Nin
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def decorate_completed
|
29
29
|
if self.completed?
|
30
30
|
'[x]'.green
|
31
31
|
else
|
@@ -33,7 +33,7 @@ module Nin
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def decorate_date
|
37
37
|
date_in_words = '@' << self.date.humanize
|
38
38
|
|
39
39
|
if self.past?
|
@@ -45,7 +45,7 @@ module Nin
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def decorate_tags
|
49
49
|
self.tags.map { |tag| tag.dup.prepend('#') }.join(' ').blue
|
50
50
|
end
|
51
51
|
end
|
data/lib/nin/todo.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
1
3
|
module Nin
|
2
4
|
class Todo
|
3
5
|
attr_accessor :items
|
@@ -71,9 +73,13 @@ module Nin
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def archive(*ids)
|
74
|
-
|
75
|
-
|
76
|
-
|
76
|
+
unless @options[:completed_only]
|
77
|
+
ids.each do |id|
|
78
|
+
item = find_by_id(id.to_i)
|
79
|
+
item.toggle_archived!
|
80
|
+
end
|
81
|
+
else
|
82
|
+
completed_unarchived_items.each(&:toggle_archived!)
|
77
83
|
end
|
78
84
|
|
79
85
|
@store.write(to_hash)
|
@@ -108,8 +114,15 @@ module Nin
|
|
108
114
|
def sync(op, store_write = false, params = {})
|
109
115
|
return unless @integration_syncrhonizer
|
110
116
|
|
111
|
-
|
112
|
-
|
117
|
+
begin
|
118
|
+
Timeout::timeout(@integration_syncrhonizer.timeout_interval) {
|
119
|
+
@integration_syncrhonizer.sync(op, params)
|
120
|
+
reset_item_indices! if store_write
|
121
|
+
}
|
122
|
+
rescue Timeout::Error
|
123
|
+
puts 'Syncing timed out. Showing local items...'
|
124
|
+
puts
|
125
|
+
end
|
113
126
|
end
|
114
127
|
|
115
128
|
def fork_sync(op, store_write = false, params = {})
|
@@ -156,6 +169,10 @@ module Nin
|
|
156
169
|
@items.where(:archived?, false)
|
157
170
|
end
|
158
171
|
|
172
|
+
def completed_unarchived_items
|
173
|
+
unarchived_items.where(:completed, true)
|
174
|
+
end
|
175
|
+
|
159
176
|
def find_by_id(id)
|
160
177
|
found_item = @items.find_by(:id, id)
|
161
178
|
|
data/lib/nin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed Saleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.1.2
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: A command line todo app that provides an easy to use CLI for everyday todo
|