goot 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d321c0390af2980c57275fc3421182059657a868
4
- data.tar.gz: fde2e5cfe3dea9431aa3d082dcca7fc9cdefbcfd
3
+ metadata.gz: a8f0e9129328433d6264e17de3e7c7b157d7ef0e
4
+ data.tar.gz: 54efebf6136144e50a4e33d87720e3f95aa28b88
5
5
  SHA512:
6
- metadata.gz: 61d0be50d738af5866fbc7632d0e9618f7aa9ffae5b4c7aa5ced9a973f8988e03b655313605eb64eeba521ae4e60358e0f71e69736cb3b265f13bd2e232b9ee8
7
- data.tar.gz: ba329e2400ab7a6d57f5155bda7e15d88c5c1604a40cf3a56530ce96f6e66bad8ca273e13569c1dbeaa8a8569ba1666eb2ddfc45d329a2a94eb555cdbcb7a7c5
6
+ metadata.gz: d942b9b81bccee83186f986c6ffbda570bbc85881fbdfc2187e007969d7c0bd28c4adc890287acc89c52a6c253a31004085c1ac304fe6e6a4fb3eb467da7969c
7
+ data.tar.gz: df88c243fb7705d5f67bbe88020225c5a6c2eb3a8b49786d9388a1662904f81f0f6ea7d8d9cd8eadbe94ce309699308d8bdab8456d55a1b17b6ddccd1b380484
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'slop'
4
+ gem 'colorize'
5
+
3
6
  # Specify your gem's dependencies in goot.gemspec
4
7
  gemspec
data/bin/goot CHANGED
@@ -5,4 +5,5 @@ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
5
 
6
6
  require 'goot'
7
7
 
8
- GoogleTasks::CLI.start
8
+ API = Goot::GoogleAPI.new
9
+ Goot::CLI.new
data/goot.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'goot/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'goot'
8
- spec.version = GoogleTasks::VERSION
8
+ spec.version = Goot::VERSION
9
9
  spec.authors = ['Conner McDaniel']
10
10
  spec.email = ['connermcd@gmail.com']
11
11
  spec.summary = %q{A command-line interface to Google Tasks das ist goot.}
@@ -19,10 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
 
22
- spec.add_runtime_dependency 'thor', '~> 0.19.0'
22
+ spec.add_runtime_dependency 'slop', '~> 3.6'
23
+ spec.add_runtime_dependency 'colorize', '~> 0.7'
23
24
  spec.add_runtime_dependency 'google-api-client', '~> 0.7'
24
25
  spec.add_development_dependency 'bundler', '~> 1.5'
25
- spec.add_development_dependency 'rake'
26
- spec.add_development_dependency 'pry'
27
- spec.add_development_dependency 'rspec', '~> 2.5'
28
26
  end
data/lib/goot.rb CHANGED
@@ -1,4 +1,6 @@
1
- require 'thor'
1
+ require 'slop'
2
+ require 'colorize'
3
+ require 'readline'
2
4
 
3
5
  require 'goot/version'
4
6
  require 'goot/google_api'
data/lib/goot/cli.rb CHANGED
@@ -1,140 +1,151 @@
1
- class GoogleTasks::CLI < Thor
2
- include Thor::Actions
3
-
4
- def initialize(*args)
5
- super
6
- @api = GoogleTasks::GoogleAPI.new
1
+ class Goot::CLI
2
+ def initialize
3
+ parse ARGV
4
+ exit unless ARGV.include? '-i' or ARGV.include? '--interactive'
5
+ while argv = Readline.readline('> ', true)
6
+ parse argv.chomp.split(' ')
7
+ end
7
8
  end
8
9
 
9
- desc 'ls', 'Displays available tasks for a given tasklist'
10
- method_option :tasklist, :aliases => '-l', :type => :numeric, :default => 0
11
- def ls
12
- tab = ' '
13
- depths = {}
14
-
15
- tasklist = @api.get_tasklist(options[:tasklist])
16
- tasks = @api.get_tasks(tasklist)
10
+ def parse(argv)
11
+ Slop.parse(argv, :help => true) do
12
+ banner 'Usage: '
13
+ on :i, :interactive, 'Put goot into interactive mode'
17
14
 
18
- say tasklist.title, :green
19
- tasks.each.with_index do |task, i|
20
- next if task.deleted
15
+ command 'ls' do
16
+ description 'List tasks, e.g. ls -l1'
17
+ on :l=, :list=, 'Specify a tasklist', :default => 0
18
+ run do |opts|
19
+ tab = ' '
20
+ depths = {}
21
21
 
22
- status = task.status == 'completed' ? '✓' : '▢'
22
+ tasklist = API.get_tasklist(get(:list).to_i)
23
+ tasks = API.get_tasks(tasklist)
23
24
 
24
- depth = 1
25
- depth += depths[task.parent] if depths.include? task.parent
26
- depths[task.id] = depth
25
+ puts tasklist.title.green
26
+ tasks.each.with_index do |task, i|
27
+ next if task.deleted
27
28
 
28
- say "#{tab * depth} #{status} #{i}: #{task.title}"
29
- say "#{tab * (depth + 1)} Notes: #{task.notes}", :yellow if task.notes
30
- end
31
- end
29
+ status = task.status == 'completed' ? '✓' : '▢'
32
30
 
33
- desc 'summary', 'Displays all task lists'
34
- def summary
35
- @api.get_lists.each.with_index do |tasklist, i|
36
- say "#{i} #{tasklist.title}"
37
- end
38
- end
31
+ depth = 1
32
+ depth += depths[task.parent] if depths.include? task.parent
33
+ depths[task.id] = depth
39
34
 
40
- desc 'toggle INDEX', 'Toggles a given task'
41
- method_option :tasklist, :aliases => '-l', :type => :numeric, :default => 0
42
- def toggle(*indices)
43
- tasklist = @api.get_tasklist(options[:tasklist])
44
- tasks = @api.get_tasks(tasklist).map(&:to_hash)
45
-
46
- indices.each do |index|
47
- task = tasks[index.to_i]
48
- task['status'] = task['completed'].nil? ? 'completed' : 'needsAction'
49
- task.delete 'completed'
50
- @api.update_task(tasklist, task)
51
-
52
- toggle_children = lambda do |parent|
53
- children = tasks.select { |t| t['parent'] == parent['id'] }
54
- children.each do |t|
55
- t['status'] = task['status']
56
- t.delete 'completed'
57
- @api.update_task(tasklist, t)
58
- toggle_children.call(t)
35
+ puts "#{tab * depth} #{status} #{i}: #{task.title}"
36
+ puts "#{tab * (depth + 1)} Notes: #{task.notes}".yellow if task.notes
37
+ end
59
38
  end
60
39
  end
61
- toggle_children.call(task)
62
- end
63
-
64
- invoke :ls, [], :tasklist => options[:tasklist]
65
- end
66
40
 
67
- desc 'clear', 'Clears completed tasks'
68
- method_option :tasklist, :aliases => '-l', :type => :numeric, :default => 0
69
- def clear
70
- tasklist = @api.get_tasklist(options[:tasklist])
71
- @api.clear_tasks(tasklist)
41
+ command 's' do
42
+ description 'Print a summary of all task lists'
43
+ run do
44
+ API.get_lists.each.with_index do |tasklist, i|
45
+ puts "#{i} #{tasklist.title}"
46
+ end
47
+ end
48
+ end
72
49
 
73
- invoke :ls, [], :tasklist => options[:tasklist]
74
- end
50
+ command 't' do
51
+ description 'Toggle a task, e.g. t 0 -l1'
52
+ on :l=, :list=, 'Specify a tasklist', :default => 0
53
+ run do |opts, args|
54
+ tasklist = API.get_tasklist(opts.to_hash[:list].to_i)
55
+ tasks = API.get_tasks(tasklist).map(&:to_hash)
56
+
57
+ # TODO: check to make sure all args are ints
58
+ args.each do |index|
59
+ task = tasks[index.to_i]
60
+ task['status'] = task['completed'].nil? ? 'completed' : 'needsAction'
61
+ task.delete 'completed'
62
+ API.update_task(tasklist, task)
63
+
64
+ toggle_children = lambda do |parent|
65
+ children = tasks.select { |t| t['parent'] == parent['id'] }
66
+ children.each do |t|
67
+ t['status'] = task['status']
68
+ t.delete 'completed'
69
+ API.update_task(tasklist, t)
70
+ toggle_children.call(t)
71
+ end
72
+ end
73
+ toggle_children.call(task)
74
+ end
75
+ end
76
+ end
75
77
 
76
- desc 'delete INDEX', 'Deletes a given task'
77
- method_option :tasklist, :aliases => '-l', :type => :numeric, :default => 0
78
- def delete(*indices)
79
- tasklist = @api.get_tasklist(options[:tasklist])
80
- tasks = @api.get_tasks(tasklist).map(&:to_hash)
78
+ command 'c' do
79
+ description 'Clear completed tasks'
80
+ on :l=, :list=, 'Specify a tasklist', :default => 0
81
+ run do |opts|
82
+ tasklist = API.get_tasklist(opts.to_hash[:list].to_i)
83
+ API.clear_tasks(tasklist)
84
+ end
85
+ end
81
86
 
82
- indices.each do |index|
83
- @api.delete_task(tasklist, tasks[index.to_i])
84
- end
87
+ command 'd' do
88
+ description 'Delete a task'
89
+ on :l=, :list=, 'Specify a tasklist', :default => 0
90
+ run do |opts, args|
91
+ tasklist = API.get_tasklist(opts.to_hash[:list].to_i)
92
+ tasks = API.get_tasks(tasklist).map(&:to_hash)
93
+
94
+ # TODO: check to make sure all args are ints
95
+ args.each do |index|
96
+ API.delete_task(tasklist, tasks[index.to_i])
97
+ end
98
+ end
99
+ end
85
100
 
86
- invoke :ls, [], :tasklist => options[:tasklist]
87
- end
101
+ command 'm' do
102
+ description 'Move a task within its list'
103
+ on :a=, :after=, 'Move task after specified index'
104
+ on :p=, :parent=, 'Make task a child of parent index'
105
+ on :l=, :list=, 'Specify a tasklist', :default => 0
106
+ run do |opts, args|
107
+ tasklist = API.get_tasklist(opts.to_hash[:list].to_i)
108
+ tasks = API.get_tasks(tasklist).map(&:to_hash)
88
109
 
89
- desc 'move INDEX', 'Moves a given task'
90
- method_option :after, :aliases => '-a', :type => :numeric
91
- method_option :parent, :aliases => '-p', :type => :numeric
92
- method_option :tasklist, :aliases => '-l', :type => :numeric, :default => 0
93
- def move(index)
94
- tasklist = @api.get_tasklist(options[:tasklist])
95
- tasks = @api.get_tasks(tasklist).map(&:to_hash)
110
+ previous = tasks[opts.to_hash[:after].to_i] if !opts.to_hash[:after].nil?
111
+ parent = tasks[opts.to_hash[:parent].to_i] if !opts.to_hash[:parent].nil?
96
112
 
97
- previous = tasks[options[:after].to_i] if !options[:after].nil?
98
- parent = tasks[options[:parent].to_i] if !options[:parent].nil?
113
+ API.move_task(tasklist, tasks[args[0].to_i], previous, parent)
114
+ end
115
+ end
99
116
 
100
- @api.move_task(tasklist, tasks[index.to_i], previous, parent)
117
+ command 'a' do
118
+ description 'Add a task'
119
+ on :a=, :after=, 'Move task after specified index'
120
+ on :p=, :parent=, 'Make task a child of parent index'
121
+ on :l=, :list=, 'Specify a tasklist', :default => 0
122
+ run do |opts, args|
123
+ tasklist = API.get_tasklist(opts.to_hash[:tasklist].to_i)
124
+ tasks = API.get_tasks(tasklist).map(&:to_hash)
101
125
 
102
- invoke :ls, [], :tasklist => options[:tasklist]
103
- end
126
+ task = { :title => args[0] }
104
127
 
105
- desc 'add NAME', 'Adds a task'
106
- method_option :after, :aliases => '-a', :type => :numeric
107
- method_option :parent, :aliases => '-p', :type => :numeric
108
- method_option :tasklist, :aliases => '-l', :type => :numeric, :default => 0
109
- def add(*names)
110
- tasklist = @api.get_tasklist(options[:tasklist])
111
- tasks = @api.get_tasks(tasklist).map(&:to_hash)
128
+ previous = tasks[opts.to_hash[:after].to_i] if !opts.to_hash[:after].nil?
129
+ parent = tasks[opts.to_hash[:parent].to_i] if !opts.to_hash[:parent].nil?
112
130
 
113
- names.each do |name|
114
- task = { :title => name }
131
+ API.insert_task(tasklist, task, previous, parent)
132
+ end
133
+ end
115
134
 
116
- previous = tasks[options[:after].to_i] if !options[:after].nil?
117
- parent = tasks[options[:parent].to_i] if !options[:parent].nil?
135
+ command 'la' do # (name)
136
+ description 'Add a task list'
137
+ run do |_, args|
138
+ tasklist = { :title => args[0] }
139
+ API.insert_tasklist(tasklist)
140
+ end
141
+ end
118
142
 
119
- @api.insert_task(tasklist, task, previous, parent)
143
+ command 'ld' do # (index)
144
+ description 'Delete a task list'
145
+ run do |_, args|
146
+ API.delete_tasklist(API.get_lists[args[0].to_i])
147
+ end
148
+ end
120
149
  end
121
-
122
- invoke :ls, [], :tasklist => options[:tasklist]
123
- end
124
-
125
- desc 'listadd NAME', 'Adds a new tasklist'
126
- def listadd(name)
127
- tasklist = {:title => name}
128
- @api.insert_tasklist(tasklist)
129
-
130
- invoke :summary, []
131
150
  end
132
-
133
- desc 'listdelete INDEX', 'Deletes a tasklist'
134
- def listdelete(index)
135
- @api.delete_tasklist(@api.get_lists[index.to_i])
136
-
137
- invoke :summary, []
138
- end
139
-
140
151
  end
@@ -3,10 +3,10 @@ require 'google/api_client/client_secrets'
3
3
  require 'google/api_client/auth/file_storage'
4
4
  require 'google/api_client/auth/installed_app'
5
5
 
6
- class GoogleTasks::GoogleAPI
6
+ class Goot::GoogleAPI
7
7
 
8
- CREDENTIAL_STORE = File.join(GoogleTasks::CONFIG_DIR, 'gtasks-oauth2.json')
9
- CLIENT_SECRET_STORE = File.join(GoogleTasks::GEM_ROOT, 'data', 'client_secrets.json')
8
+ CREDENTIAL_STORE = File.join(Goot::CONFIG_DIR, 'gtasks-oauth2.json')
9
+ CLIENT_SECRET_STORE = File.join(Goot::GEM_ROOT, 'data', 'client_secrets.json')
10
10
 
11
11
  UNCHANGED = 0
12
12
  MODIFIED = 1
@@ -14,8 +14,8 @@ class GoogleTasks::GoogleAPI
14
14
 
15
15
  def initialize
16
16
  client = Google::APIClient.new(
17
- :application_name => GoogleTasks::APP_NAME,
18
- :application_version => GoogleTasks::VERSION
17
+ :application_name => Goot::APP_NAME,
18
+ :application_version => Goot::VERSION
19
19
  )
20
20
 
21
21
  file_storage = Google::APIClient::FileStorage.new(CREDENTIAL_STORE)
data/lib/goot/version.rb CHANGED
@@ -1,6 +1,6 @@
1
- module GoogleTasks
1
+ module Goot
2
2
  APP_NAME = 'goot'
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
 
5
5
  GEM_ROOT = File.expand_path('../../..', __FILE__)
6
6
  CONFIG_DIR = File.join(ENV['HOME'], '.goot')
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conner McDaniel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-21 00:00:00.000000000 Z
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: thor
14
+ name: slop
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.19.0
19
+ version: '3.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.19.0
26
+ version: '3.6'
27
27
  - !ruby/object:Gem::Dependency
28
- name: google-api-client
28
+ name: colorize
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
@@ -39,61 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.7'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: google-api-client
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.5'
48
- type: :development
47
+ version: '0.7'
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.5'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
54
+ version: '0.7'
83
55
  - !ruby/object:Gem::Dependency
84
- name: rspec
56
+ name: bundler
85
57
  requirement: !ruby/object:Gem::Requirement
86
58
  requirements:
87
59
  - - "~>"
88
60
  - !ruby/object:Gem::Version
89
- version: '2.5'
61
+ version: '1.5'
90
62
  type: :development
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: '2.5'
68
+ version: '1.5'
97
69
  description: A command-line interface to Google Tasks das ist goot.
98
70
  email:
99
71
  - connermcd@gmail.com