wunderlist-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/wunderlist +6 -0
- data/lib/cli.rb +17 -0
- data/lib/cli/base.rb +63 -0
- data/lib/cli/client.rb +29 -0
- data/lib/cli/lists.rb +66 -0
- data/wunderlist-cli.gemspec +23 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2899f09e53e40eb896d2397abb28c7bb87597dcc
|
4
|
+
data.tar.gz: c1183acb36ce73d22f0b8b121c0b283f612e464e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 183cb26ffcb9f7aefdc8378925388dc26d23c18b39ab59066655c56c3dea081b331becec318a1f3426a8eb06a5f970263fa8fcf5390b71ffae847a5c21340a47
|
7
|
+
data.tar.gz: 37ab0540f1ed7079e09a3d679d7349c6806e65b81a4536fd0fe3bbd8dfb2254be6bdecba421e8df15909afb5b2c2320a03c6b76cf99e67e2181aae73b0ad6681
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Sebastian Gräßl
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Wunderlist::Cli
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'wunderlist-cli'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install wunderlist-cli
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/wunderlist
ADDED
data/lib/cli.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'thor'
|
3
|
+
require 'fog/wunderlist'
|
4
|
+
|
5
|
+
module Cli
|
6
|
+
module Ui
|
7
|
+
def puts_padded(left, padding=" ", right=nil)
|
8
|
+
left = left[0, 60] if left.length > 60
|
9
|
+
pad_to = right ? 80-right.size : 80
|
10
|
+
puts (left.ljust(pad_to, (padding)) + (right||""))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'cli/client'
|
16
|
+
require 'cli/lists'
|
17
|
+
require 'cli/base'
|
data/lib/cli/base.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
module Cli
|
2
|
+
class Base < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
include Client
|
5
|
+
include Lists
|
6
|
+
include Ui
|
7
|
+
|
8
|
+
default_task :all
|
9
|
+
|
10
|
+
desc "setup", "Setup authentication"
|
11
|
+
def setup
|
12
|
+
load_config
|
13
|
+
config[:username] = ask("Username: ")
|
14
|
+
config[:password] = ask("Password: ")
|
15
|
+
wirte_config
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "all", "Display all lists"
|
19
|
+
option :list, :type => :string, :aliases => :l,
|
20
|
+
:banner => "Only show tasks of a specific list"
|
21
|
+
def all
|
22
|
+
task_lists = client.tasks.find_all { |t| t.completed_at.nil? }
|
23
|
+
|
24
|
+
if options[:list]
|
25
|
+
task_lists = task_lists.find_all { |t| t.list_id == options[:list] }
|
26
|
+
end
|
27
|
+
|
28
|
+
show_list_list(task_lists.group_by { |t| t.list_id })
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "add TODO", "Add a new todo"
|
32
|
+
option :list, :type => :string, :aliases => :l, :default => 'inbox',
|
33
|
+
:banner => "Provide a LIST_ID to add the todo to"
|
34
|
+
def add(todo = nil)
|
35
|
+
todo = ask("What to do?") unless todo
|
36
|
+
list_id = options[:list]
|
37
|
+
|
38
|
+
max_position = client.tasks.find_all{ |t| t.list_id == list_id }
|
39
|
+
.sort_by { |t| t.position }[0]
|
40
|
+
|
41
|
+
client.tasks.create(title: todo, list_id: list_id, position: max_position.position-0.1)
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "complete TODO_ID", "Complete a todo"
|
45
|
+
def completed(todo_id)
|
46
|
+
task = client.tasks.find { |t| t.id == todo_id }
|
47
|
+
task.completed_at = Time.now.to_s
|
48
|
+
task.save
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "delete TODO_ID", "Delete a todo"
|
52
|
+
def delete(todo_id)
|
53
|
+
task = client.tasks.find { |t| t.id == todo_id }
|
54
|
+
task.destroy
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "all_lists", "Show all lists"
|
58
|
+
def all_lists
|
59
|
+
lists_list
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
data/lib/cli/client.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Cli
|
2
|
+
module Client
|
3
|
+
attr_accessor :config
|
4
|
+
|
5
|
+
def client
|
6
|
+
load_config
|
7
|
+
|
8
|
+
@client ||= Fog::Tasks.new(:provider => 'Wunderlist',
|
9
|
+
:wunderlist_username => config[:username],
|
10
|
+
:wunderlist_password => config[:password])
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_config
|
14
|
+
if File.exists?(config_file)
|
15
|
+
@config ||= YAML::load_file(config_file)
|
16
|
+
else
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def save_config
|
22
|
+
File.open(self.class.config_file, 'w') {|f| f.write old_config.to_yaml }
|
23
|
+
end
|
24
|
+
|
25
|
+
def config_file
|
26
|
+
File.join(ENV['HOME'], '.wunderlist')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/cli/lists.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
module Cli
|
2
|
+
module Lists
|
3
|
+
|
4
|
+
def lists
|
5
|
+
@lists ||= client.lists
|
6
|
+
end
|
7
|
+
|
8
|
+
def show_list_list(tasks_lists)
|
9
|
+
inbox_first(tasks_lists).each do |list, tasks|
|
10
|
+
show_task_list(list, tasks)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def ask_for_list
|
15
|
+
lists_list
|
16
|
+
|
17
|
+
list_index = ask("Add to list?")
|
18
|
+
|
19
|
+
if list_index.to_i == 1 || list_index.empty?
|
20
|
+
'inbox'
|
21
|
+
else
|
22
|
+
lists[list_index.to_i-2]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def lists_list
|
27
|
+
puts "1. Inbox"
|
28
|
+
|
29
|
+
lists.each_with_index do |list, idx|
|
30
|
+
puts "#{idx+2}. #{list.title} (ID: #{list.id})"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def list_title_for(list)
|
35
|
+
if list == 'inbox'
|
36
|
+
list = OpenStruct.new({ title: "Inbox", id: '' })
|
37
|
+
else
|
38
|
+
list = lists.find{ |l| l.id == list }
|
39
|
+
end
|
40
|
+
|
41
|
+
puts_padded list.title, " ", list.id
|
42
|
+
puts_padded '', "="
|
43
|
+
end
|
44
|
+
|
45
|
+
def show_task_list(list, tasks)
|
46
|
+
list_title_for(list)
|
47
|
+
|
48
|
+
tasks.sort_by {|t| t.created_at.to_i }.reverse.each do |task|
|
49
|
+
puts_padded " - #{task.title}", " ", task.id
|
50
|
+
end
|
51
|
+
|
52
|
+
puts ''.ljust(80, " ")
|
53
|
+
end
|
54
|
+
|
55
|
+
def inbox_first(tasks_list)
|
56
|
+
inbox = tasks_list.find{ |l, t| l == 'inbox' }
|
57
|
+
if inbox
|
58
|
+
show_task_list(inbox[0], inbox[1])
|
59
|
+
tasks_list.delete_if{|l, t| l == 'inbox' }
|
60
|
+
end
|
61
|
+
|
62
|
+
tasks_list
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "wunderlist-cli"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Sebastian Gräßl"]
|
9
|
+
spec.email = ["sebastian@validcode.me"]
|
10
|
+
spec.description = "A Wunderlist command-line interface"
|
11
|
+
spec.summary = "A Wunderlist command-line interface"
|
12
|
+
spec.homepage = "https://github.com/bastilian/wunderlist-cli"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
spec.add_dependency "fog-wunderlist"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wunderlist-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sebastian Gräßl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fog-wunderlist
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A Wunderlist command-line interface
|
70
|
+
email:
|
71
|
+
- sebastian@validcode.me
|
72
|
+
executables:
|
73
|
+
- wunderlist
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/wunderlist
|
83
|
+
- lib/cli.rb
|
84
|
+
- lib/cli/base.rb
|
85
|
+
- lib/cli/client.rb
|
86
|
+
- lib/cli/lists.rb
|
87
|
+
- wunderlist-cli.gemspec
|
88
|
+
homepage: https://github.com/bastilian/wunderlist-cli
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.0.6
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: A Wunderlist command-line interface
|
112
|
+
test_files: []
|