trello_cli 0.0.1 → 0.0.2

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.
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## 0.0.2:
2
+
3
+ * Refactored CLI
4
+ * Added list cards
5
+
6
+ ## 0.0.1:
7
+
8
+ * Initial release
data/README.md CHANGED
@@ -16,9 +16,13 @@ Get API key:
16
16
 
17
17
  https://trello.com/1/appKey/generate
18
18
 
19
- Get member token:
19
+ Get read only member token:
20
20
 
21
- https://trello.com/1/connect?key=$YOUR_API_KEY&name=MY_APP_NAME&response_type=token
21
+ https://trello.com/1/connect?key=YOUR_API_KEY&name=trello-cli&response_type=token
22
+
23
+ Get read / write member token:
24
+
25
+ https://trello.com/1/authorize?key=YOUR_API_KEY&name=trello-cli=1day&response_type=token&scope=read,write
22
26
 
23
27
  Set the environment variables:
24
28
 
@@ -37,7 +41,7 @@ For example, to list the boards available to the given credentials:
37
41
 
38
42
  to list the lists for a given board id:
39
43
 
40
- trello list list -b 123
44
+ trello list list -b 123
41
45
 
42
46
  To create a card:
43
47
 
@@ -0,0 +1,41 @@
1
+ module TrelloCli
2
+ module CLI
3
+ module Board
4
+ class List
5
+
6
+ def initialize
7
+ @options = {}
8
+ end
9
+
10
+ def run
11
+ option_parser.parse!
12
+
13
+ list_boards.each do |list|
14
+ name = list.attributes[:name]
15
+ id = list.attributes[:id]
16
+
17
+ puts "#{name} ( #{id} )"
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def list_boards
24
+ lb = TrelloCli::Requests::ListBoards.new
25
+ lb.list
26
+ end
27
+
28
+ def option_parser(options=@options)
29
+ OptionParser.new do |opts|
30
+ opts.banner = "Usage: trello board [list]"
31
+ end
32
+ end
33
+
34
+ def help
35
+ puts option_parser.help
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,35 +1 @@
1
- module TrelloCli
2
- module CLI
3
- class Board
4
-
5
- include Shared
6
-
7
- def initialize
8
- @options = {}
9
- end
10
-
11
- def list
12
- list_boards.each do |list|
13
- name = list.attributes[:name]
14
- id = list.attributes[:id]
15
-
16
- puts "#{name} ( #{id} )"
17
- end
18
- end
19
-
20
- private
21
-
22
- def list_boards
23
- lb = TrelloCli::Requests::ListBoards.new
24
- lb.list
25
- end
26
-
27
- def option_parser(options=@options)
28
- OptionParser.new do |opts|
29
- opts.banner = "Usage: trello board [list]"
30
- end
31
- end
32
-
33
- end
34
- end
35
- end
1
+ require 'trello_cli/cli/board/list'
@@ -0,0 +1,58 @@
1
+ module TrelloCli
2
+ module CLI
3
+ module Card
4
+ class Create
5
+
6
+ def initialize
7
+ @options = {}
8
+ end
9
+
10
+ def run
11
+ option_parser.parse!
12
+
13
+ card = create_card
14
+ name = card.attributes[:name]
15
+ description = card.attributes[:description]
16
+
17
+ puts "Card Created."
18
+ puts "Name : #{name}"
19
+ puts "Description : #{description}"
20
+ end
21
+
22
+ private
23
+
24
+ def create_card
25
+ cc = TrelloCli::Requests::CreateCard.new
26
+ cc.create @options
27
+ end
28
+
29
+ def option_parser
30
+ OptionParser.new do |opts|
31
+ opts.banner = "Usage: trello card [create] [options]"
32
+
33
+ opts.on("-b", "--board [BOARD]", "Trello Board Id") do |b|
34
+ @options[:board_id] = b
35
+ end
36
+
37
+ opts.on("-d", "--description [DESCRIPTION]", "Description Of Card") do |d|
38
+ @options[:description] = d
39
+ end
40
+
41
+ opts.on("-l", "--list [LIST]", "List Of Card") do |l|
42
+ @options[:list_id] = l
43
+ end
44
+
45
+ opts.on("-n", "--name [NAME]", "Name Of Card") do |n|
46
+ @options[:name] = n
47
+ end
48
+ end
49
+ end
50
+
51
+ def help
52
+ puts option_parser.help
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,47 @@
1
+ module TrelloCli
2
+ module CLI
3
+ module Card
4
+ class List
5
+
6
+ def initialize
7
+ @options = {}
8
+ end
9
+
10
+ def run
11
+ option_parser.parse!
12
+
13
+ list_cards.each do |card|
14
+ puts "| Name: #{card.name}"
15
+ puts "| Description: #{card.name}"
16
+ puts "|------------------------"
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def list_cards
23
+ TrelloCli::Requests::ListCards.new.list @options
24
+ end
25
+
26
+ def option_parser
27
+ OptionParser.new do |opts|
28
+ opts.banner = "Usage: trello card [create] [options]"
29
+
30
+ opts.on("-b", "--board [BOARD]", "Trello Board Id") do |b|
31
+ @options[:board_id] = b
32
+ end
33
+
34
+ opts.on("-l", "--list [LIST]", "List To Query") do |l|
35
+ @options[:list_id] = l
36
+ end
37
+ end
38
+ end
39
+
40
+ def help
41
+ puts option_parser.help
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,55 +1,2 @@
1
- module TrelloCli
2
- module CLI
3
- class Card
4
-
5
- include Shared
6
-
7
- def initialize
8
- @options = {}
9
- end
10
-
11
- def create
12
- parse_options
13
-
14
- card = create_card
15
- name = card.attributes[:name]
16
- description = card.attributes[:description]
17
-
18
- puts "Card Created."
19
- puts "Name : #{name}"
20
- puts "Description : #{description}"
21
- end
22
-
23
- private
24
-
25
- def create_card
26
- cc = TrelloCli::Requests::CreateCard.new
27
- cc.create @options
28
- end
29
-
30
- def option_parser
31
- OptionParser.new do |opts|
32
- opts.banner = "Usage: trello card [create] [options]"
33
-
34
- opts.on("-b", "--board [BOARD]", "Trello Board Id") do |b|
35
- @options[:board_id] = b
36
- end
37
-
38
- opts.on("-d", "--description [DESCRIPTION]", "Description Of Card") do |d|
39
- @options[:description] = d
40
- end
41
-
42
- opts.on("-l", "--list [LIST]", "List Of Card") do |l|
43
- @options[:list_id] = l
44
- end
45
-
46
- opts.on("-n", "--name [NAME]", "Name Of Card") do |n|
47
- @options[:name] = n
48
- end
49
- end
50
- end
51
-
52
-
53
- end
54
- end
55
- end
1
+ require 'trello_cli/cli/card/create'
2
+ require 'trello_cli/cli/card/list'
@@ -0,0 +1,15 @@
1
+ module TrelloCli
2
+ module CLI
3
+ module Commands
4
+ class Board
5
+
6
+ include Shared
7
+
8
+ def list
9
+ TrelloCli::CLI::Board::List.new.run
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ module TrelloCli
2
+ module CLI
3
+ module Commands
4
+ class Card
5
+
6
+ include Shared
7
+
8
+ def create
9
+ TrelloCli::CLI::Card::Create.new.run
10
+ end
11
+
12
+ def list
13
+ TrelloCli::CLI::Card::List.new.run
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module TrelloCli
2
+ module CLI
3
+ module Commands
4
+ class List
5
+
6
+ include Shared
7
+
8
+ def list
9
+ TrelloCli::CLI::List::List.new.run
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ module TrelloCli
2
+ module CLI
3
+ module Commands
4
+ module Shared
5
+
6
+ def actions(obj = self)
7
+ (obj.methods - obj.class.superclass.instance_methods).sort - shared_methods
8
+ end
9
+
10
+ def shared_methods
11
+ TrelloCli::CLI::Commands::Shared.instance_methods
12
+ end
13
+
14
+ def help
15
+ puts "Valid Sub Commands: #{actions.join(' ')}"
16
+ puts "For further help, append -h to sub command."
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ require 'trello_cli/cli/commands/shared'
2
+
3
+ require 'trello_cli/cli/commands/board'
4
+ require 'trello_cli/cli/commands/card'
5
+ require 'trello_cli/cli/commands/list'
@@ -0,0 +1,47 @@
1
+ module TrelloCli
2
+ module CLI
3
+ module List
4
+ class List
5
+
6
+ def initialize
7
+ @options = {}
8
+ end
9
+
10
+ def run
11
+ option_parser.parse!
12
+
13
+ list_lists.each do |list|
14
+ name = list.attributes[:name]
15
+ id = list.attributes[:id]
16
+
17
+ puts "#{name} ( #{id} )"
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def list_lists
24
+ ll = TrelloCli::Requests::ListLists.new
25
+ ll.list @options
26
+ end
27
+
28
+ def option_parser
29
+ OptionParser.new do |opts|
30
+
31
+ opts.banner = "Usage: trello list [list] [options]"
32
+
33
+ opts.on("-b", "--board [BOARD]", "Trello Board Id") do |b|
34
+ @options[:board_id] = b
35
+ end
36
+
37
+ end
38
+ end
39
+
40
+ def help
41
+ puts option_parser.help
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,43 +1 @@
1
- module TrelloCli
2
- module CLI
3
- class List
4
-
5
- include Shared
6
-
7
- def initialize
8
- @options = {}
9
- end
10
-
11
- def list
12
- parse_options
13
-
14
- list_lists.each do |list|
15
- name = list.attributes[:name]
16
- id = list.attributes[:id]
17
-
18
- puts "#{name} ( #{id} )"
19
- end
20
- end
21
-
22
- private
23
-
24
- def list_lists
25
- ll = TrelloCli::Requests::ListLists.new
26
- ll.list @options
27
- end
28
-
29
- def option_parser
30
- OptionParser.new do |opts|
31
-
32
- opts.banner = "Usage: trello list [list] [options]"
33
-
34
- opts.on("-b", "--board [BOARD]", "Trello Board Id") do |b|
35
- @options[:board_id] = b
36
- end
37
-
38
- end
39
- end
40
-
41
- end
42
- end
43
- end
1
+ require 'trello_cli/cli/list/list'
@@ -7,11 +7,16 @@ module TrelloCli
7
7
 
8
8
  case target
9
9
  when *targets
10
- target_object = CLI.const_get(target.capitalize).new
10
+ target_object = CLI::Commands.const_get(target.capitalize).new
11
11
 
12
12
  cmd = 'help' unless target_object.actions.include?(cmd.to_sym)
13
13
 
14
- target_object.send cmd
14
+ begin
15
+ target_object.send cmd
16
+ rescue OptionParser::InvalidOption, Trello::Error => e
17
+ puts e.message
18
+ exit 1
19
+ end
15
20
  when '-v'
16
21
  puts TrelloCli::VERSION
17
22
  else
@@ -25,7 +30,7 @@ module TrelloCli
25
30
 
26
31
  def targets
27
32
  klasses = TrelloCli::CLI.constants.reject do |c|
28
- ( c == :Run ) || ( c == :Shared )
33
+ ( c == :Run ) || ( c == :Commands )
29
34
  end
30
35
  klasses.map { |k| k.to_s.downcase }
31
36
  end
@@ -1,6 +1,6 @@
1
1
  require 'optparse'
2
2
 
3
- require 'trello_cli/cli/shared'
3
+ require 'trello_cli/cli/commands'
4
4
  require 'trello_cli/cli/run'
5
5
 
6
6
  require 'trello_cli/cli/board'
@@ -0,0 +1,19 @@
1
+ module TrelloCli
2
+ module Requests
3
+ class ListCards
4
+
5
+ include Shared
6
+
7
+ def initialize
8
+ connect_to_trello
9
+ end
10
+
11
+ def list(args)
12
+ list = Trello::List.new 'idBoard' => args[:board_id],
13
+ 'id' => args[:list_id]
14
+ list.cards
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -4,4 +4,5 @@ require 'trello_cli/requests/shared'
4
4
 
5
5
  require 'trello_cli/requests/create_card'
6
6
  require 'trello_cli/requests/list_boards'
7
+ require 'trello_cli/requests/list_cards'
7
8
  require 'trello_cli/requests/list_lists'
@@ -1,3 +1,3 @@
1
1
  module TrelloCli
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/cli/run_spec.rb CHANGED
@@ -4,7 +4,7 @@ describe TrelloCli::CLI::Run do
4
4
 
5
5
  before do
6
6
  @card_mock = mock 'card'
7
- TrelloCli::CLI::Card.stub :new => @card_mock
7
+ TrelloCli::CLI::Commands::Card.stub :new => @card_mock
8
8
  end
9
9
 
10
10
  it "should call the given target with sub command" do
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe TrelloCli::Requests::ListCards do
4
+ before do
5
+ Trello.should_receive(:configure)
6
+ end
7
+
8
+ it "should create the requested card" do
9
+ args = { :board_id => '123',
10
+ :list_id => '321' }
11
+ options = { 'idBoard' => args[:board_id],
12
+ 'id' => args[:list_id] }
13
+ trello_list_mock = mock 'trello list'
14
+ Trello::List.should_receive(:new).
15
+ with(options).
16
+ and_return trello_list_mock
17
+ trello_list_mock.should_receive(:cards)
18
+ list_cards = TrelloCli::Requests::ListCards.new
19
+ list_cards.list args
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trello_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-13 00:00:00.000000000 Z
12
+ date: 2013-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70361510553800 !ruby/object:Gem::Requirement
16
+ requirement: &70367038643300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70361510553800
24
+ version_requirements: *70367038643300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70361510553300 !ruby/object:Gem::Requirement
27
+ requirement: &70367038642840 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70361510553300
35
+ version_requirements: *70367038642840
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ruby-trello
38
- requirement: &70361510552800 !ruby/object:Gem::Requirement
38
+ requirement: &70367038642300 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.5.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70361510552800
46
+ version_requirements: *70367038642300
47
47
  description: Simple Trello Command Line Interface
48
48
  email:
49
49
  - brett@weav.net
@@ -55,6 +55,7 @@ files:
55
55
  - .gitignore
56
56
  - .rvmrc
57
57
  - .travis.yml
58
+ - CHANGELOG.md
58
59
  - Gemfile
59
60
  - LICENSE.txt
60
61
  - README.md
@@ -63,19 +64,29 @@ files:
63
64
  - lib/trello_cli.rb
64
65
  - lib/trello_cli/cli.rb
65
66
  - lib/trello_cli/cli/board.rb
67
+ - lib/trello_cli/cli/board/list.rb
66
68
  - lib/trello_cli/cli/card.rb
69
+ - lib/trello_cli/cli/card/create.rb
70
+ - lib/trello_cli/cli/card/list.rb
71
+ - lib/trello_cli/cli/commands.rb
72
+ - lib/trello_cli/cli/commands/board.rb
73
+ - lib/trello_cli/cli/commands/card.rb
74
+ - lib/trello_cli/cli/commands/list.rb
75
+ - lib/trello_cli/cli/commands/shared.rb
67
76
  - lib/trello_cli/cli/list.rb
77
+ - lib/trello_cli/cli/list/list.rb
68
78
  - lib/trello_cli/cli/run.rb
69
- - lib/trello_cli/cli/shared.rb
70
79
  - lib/trello_cli/requests.rb
71
80
  - lib/trello_cli/requests/create_card.rb
72
81
  - lib/trello_cli/requests/list_boards.rb
82
+ - lib/trello_cli/requests/list_cards.rb
73
83
  - lib/trello_cli/requests/list_lists.rb
74
84
  - lib/trello_cli/requests/shared.rb
75
85
  - lib/trello_cli/version.rb
76
86
  - spec/cli/run_spec.rb
77
87
  - spec/requests/create_card_spec.rb
78
88
  - spec/requests/list_boards_spec.rb
89
+ - spec/requests/list_card_spec.rb
79
90
  - spec/requests/list_lists_spec.rb
80
91
  - spec/requests/shared_spec.rb
81
92
  - spec/spec_helper.rb
@@ -94,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
105
  version: '0'
95
106
  segments:
96
107
  - 0
97
- hash: -3766021795283727408
108
+ hash: -566414765943541531
98
109
  required_rubygems_version: !ruby/object:Gem::Requirement
99
110
  none: false
100
111
  requirements:
@@ -103,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
114
  version: '0'
104
115
  segments:
105
116
  - 0
106
- hash: -3766021795283727408
117
+ hash: -566414765943541531
107
118
  requirements: []
108
119
  rubyforge_project:
109
120
  rubygems_version: 1.8.16
@@ -114,6 +125,7 @@ test_files:
114
125
  - spec/cli/run_spec.rb
115
126
  - spec/requests/create_card_spec.rb
116
127
  - spec/requests/list_boards_spec.rb
128
+ - spec/requests/list_card_spec.rb
117
129
  - spec/requests/list_lists_spec.rb
118
130
  - spec/requests/shared_spec.rb
119
131
  - spec/spec_helper.rb
@@ -1,19 +0,0 @@
1
- module TrelloCli
2
- module CLI
3
- module Shared
4
-
5
- def actions(obj = self)
6
- (obj.methods - obj.class.superclass.instance_methods).sort
7
- end
8
-
9
- def parse_options
10
- option_parser.parse!
11
- end
12
-
13
- def help
14
- puts option_parser.help
15
- end
16
-
17
- end
18
- end
19
- end