idonethis-cli 0.9.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2241e35ab706407f845b7c6f22f9730678b946b5
4
- data.tar.gz: 096c45fc3e72c9b0c017356d0a38d245a9cd094d
3
+ metadata.gz: 1aeb6df78450b020a26bbfa41c54862eeff62b3b
4
+ data.tar.gz: 31d09301f3e72752a010741b073a772ce00d10ad
5
5
  SHA512:
6
- metadata.gz: 83dec6690145bf4ad74e3aa374c5257505fbc299f90aea692e7b332bfe50c999612ddfd6911c2f9c62e0cf37c71332f52abbe421749bbb4603747201433f80ca
7
- data.tar.gz: 9004b49f1f12c25592f5de916a57a191e25ea8a8cde71788f2715abe56b82cf99dd3914643a0364a24a7c4220da1081c4fac7100cf4991b48b162c8ff9a49390
6
+ metadata.gz: b78e5edd6a1b330577d96b53c5e0313774c09b2608b6e1deb17f0543ca81d3ad0b8bd6174922418f3f0901282cc5734373fea9d969fa7b8a52a1b54ce21f5371
7
+ data.tar.gz: 1212752ebc36fb9ae0d4d47c35bbef138013fff7c8c08f7559c99becf406c9634534c222cf6a703aaeeebdcf7eaa5b54bcb5108f4ebd7c8dfd4125adfb3a081a
data/lib/adapters/cli.rb CHANGED
@@ -12,6 +12,8 @@ module Idonethis::Adapters
12
12
 
13
13
  command,*rest = argv
14
14
 
15
+ command = "help" unless command
16
+
15
17
  log = choose_log(args)
16
18
 
17
19
  args.merge!({ opts: rest, log: log, internet: Idonethis::Adapters::Internet, view: Idonethis::Adapters::Views::Cli::List.method(:apply)})
@@ -62,6 +64,10 @@ module Idonethis::Adapters
62
64
  opts.on("-d", "Dry run") do |_|
63
65
  args[:dry_run] = true
64
66
  end
67
+
68
+ opts.on("-t TEAM", "--team TEAM" "Run against this team") do |team_name|
69
+ args[:team] = team_name
70
+ end
65
71
  end.parse!
66
72
 
67
73
  args
@@ -1,5 +1,5 @@
1
1
  module Idonethis
2
2
  module Cli
3
- VERSION = "0.9.0"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
@@ -32,7 +32,7 @@ module Idonethis::UseCases
32
32
  def get_page(page, credential, log, args) # https://idonethis.com/api/v0.1/dones/
33
33
  params = {"order_by" => "-created", "page_size" => 100, "page" => page}.
34
34
  merge(done_date_from(args)).
35
- merge({team: credential[:team]})
35
+ merge({team: (args[:team] || credential[:team])})
36
36
 
37
37
  url = Idonethis::Index.dones(params)
38
38
 
@@ -44,11 +44,13 @@ module Idonethis::UseCases
44
44
  end
45
45
 
46
46
  def done_date_from(args)
47
- if args[:opts].include?("week")
47
+ opts = args[:opts] || []
48
+
49
+ if opts.include?("week")
48
50
  return { done_date_after: (Time.now - (7*24*60*60)).strftime("%F") }
49
51
  end
50
52
 
51
- intersection = (args[:opts] || []) & %W{ today yesterday }
53
+ intersection = opts & %W{ today yesterday }
52
54
 
53
55
  return intersection.empty? ? { done_date: 'today' } : { done_date: intersection.first }
54
56
  end
@@ -4,13 +4,17 @@ module Idonethis::UseCases
4
4
  def apply(credential, args={})
5
5
  log = args[:log] || fail("You need to supply :internet adapter")
6
6
  internet = args[:internet] || fail("You need to supply :internet adapter")
7
-
7
+ team = args[:team]
8
+
8
9
  log.call "args: #{args}"
10
+ log.call "overriding team <#{credential[:team]}> with <#{team}>"
9
11
 
10
12
  parse internet.post(
11
13
  Idonethis::Index.dones,
12
14
  { "Authorization" => "Token #{credential[:token]}", accept: "application/json"},
13
- { "raw_text" => args[:message], "team" => credential[:team]})
15
+ {
16
+ "raw_text" => args[:message],
17
+ "team" => (team || credential[:team])})
14
18
  end
15
19
 
16
20
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idonethis-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Biddington