idonethis-cli 0.13.3 → 0.14.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: ad72f615c54b128363ee1c9fd8699c959e1a8ab4
4
- data.tar.gz: 4ca4a45b5f536128f08f6539f770c48a4ca3aefd
3
+ metadata.gz: 39ea043466d1cea8537c68e88e79328c7aaeadba
4
+ data.tar.gz: de281215fdcaa551d955ecedbbb65f04ac66c06f
5
5
  SHA512:
6
- metadata.gz: ab930ebcf25bce33c13366ff66389c7356bc57940ab688aa2ca469efcea2d047bf834b527dc7d5d5700abde63fcbb0179ee22ee940797bb1d6b91e0598f3f2f2
7
- data.tar.gz: e50373789f9eaffa75133cc1e0dc747bcb6fa06c3faebb8d40d26765b4e325e9a6d7e40cdcaf4a7587e80f78815b10937d39d9ff517a1104b770be9c5e4551f6
6
+ metadata.gz: aa299c2246ce2f707bab10444dde810740a8d324b553c491e577e1fdfe1b8f9e4a4db2e52c59806fd66f11c8a3dc41cfaee4409b4eee9e664cf83fef9221c2ca
7
+ data.tar.gz: 25d51e60620ec46dbfc5ce3616ec9f80c93f3a431bcdf09eedbf0802e185015a86ded4a7af18c9f7c642da56c567d6b86833bb4f26ca11c44d4f909658f52a74
data/lib/adapters/cli.rb CHANGED
@@ -9,84 +9,17 @@ module Idonethis::Adapters
9
9
  class Cli
10
10
  class << self
11
11
  def run(argv={})
12
- args = parse(argv)
13
-
14
- command,*rest = argv
15
-
16
- command = "help" unless command
17
-
18
- log = choose_log(args)
19
-
20
- args.merge!({ opts: rest, log: log, internet: Idonethis::Adapters::Internet, view: Idonethis::Adapters::Views::Cli::List.method(:apply)})
21
- credential = Settings.credential
22
-
23
- log.call "args: #{args}, command: #{command}, rest: #{rest}"
24
-
25
- use_case = choose command.to_sym, rest
26
-
27
- unless use_case
28
- log.call "No command <#{command.to_sym}> found"
29
- return
30
- end
31
-
32
- use_case.call credential, args
33
- end
34
-
35
- private
36
-
37
- def choose(command, opts)
38
- use_cases = {
39
- list: Idonethis::UseCases::List.method(:apply),
40
- new: Idonethis::UseCases::New.method(:apply),
41
- config: Idonethis::UseCases::Config.method(:apply),
42
- git: ->(_, args) { Idonethis::UseCases::Git.apply(_, args.merge(git: Idonethis::Adapters::Git, view: ->(msg) { puts msg }, fs: Idonethis::Adapters::IO::DirectoryInfo))},
43
- help: ->(credential, args) { puts "TODO: implement help" }
44
- }
45
-
46
- if command == :list && opts.include?("teams")
47
- return ->(credential, args) {
48
- Idonethis::UseCases::Teams.apply(credential, args.merge(view: Idonethis::Adapters::Views::Cli::Teams.method(:apply)))
49
- }
50
- end
51
-
52
- use_case = use_cases[command]
53
- end
54
-
55
- def choose_log(args={})
56
- args[:verbose] == true ? ->(msg){puts "[LOG] #{msg}"} : ->(_){}
57
- end
58
-
59
- def parse(argv={})
60
- args = {}
61
-
62
- require 'optparse'
63
-
64
- OptionParser.new do |opts|
65
- opts.banner = "Usage: command [options]"
66
-
67
- opts.on("-v", "--verbose", "Run verbosely") do |v|
68
- args[:verbose] = v
69
- end
70
-
71
- opts.on("-m MESSAGE", "Message") do |m|
72
- args[:message] = m
73
- end
74
-
75
- opts.on("-d", "Dry run") do |_|
76
- args[:dry_run] = true
77
- end
78
-
79
- opts.on("-t TEAM", "--team TEAM" "Run against this team") do |team_name|
80
- args[:team] = team_name
81
- end
82
-
83
- opts.on("-s WHEN", "--since WHEN" "Show git commits since when") do |value|
84
- args[:since] = value
85
- end
86
- end.parse!
87
-
88
- args
12
+ adapters = {
13
+ internet: Idonethis::Adapters::Internet,
14
+ git: Idonethis::Adapters::Git,
15
+ fs: Idonethis::Adapters::IO::DirectoryInfo,
16
+ views: { list: Idonethis::Adapters::Views::Cli::List.method(:apply)},
17
+ settings: Settings,
18
+ log: ->(msg){puts "[LOG] #{msg}"}}
19
+
20
+ Idonethis::UseCases::Cli.apply argv, adapters
89
21
  end
90
22
  end
91
23
  end
92
24
  end
25
+
@@ -1,5 +1,5 @@
1
1
  module Idonethis
2
2
  module Cli
3
- VERSION = "0.13.3"
3
+ VERSION = "0.14.0"
4
4
  end
5
5
  end
@@ -0,0 +1,87 @@
1
+ module Idonethis::UseCases
2
+ class Cli
3
+ class << self
4
+ def apply(argv={}, adapters={})
5
+ args = parse(argv)
6
+
7
+ command,*rest = argv
8
+
9
+ command = "help" unless command
10
+
11
+ log = args[:verbose] == true ? adapters[:log] : ->(_){}
12
+ internet = adapters[:internet]
13
+ views = adapters[:views] || fail("You need to supply the :views adapter")
14
+ settings = adapters[:settings] || fail("You need to supply the :settings adapters")
15
+
16
+ args.merge!({ opts: rest, log: log, internet: internet, view: views[:list]})
17
+
18
+ log.call "args: #{args}, command: #{command}, rest: #{rest}"
19
+
20
+ use_case = choose command.to_sym, adapters, rest
21
+
22
+ unless use_case
23
+ log.call "No command <#{command.to_sym}> found"
24
+ return
25
+ end
26
+
27
+ use_case.call settings.credential, args
28
+ end
29
+
30
+ private
31
+
32
+ def choose(command, adapters, opts)
33
+ use_cases = {
34
+ list: Idonethis::UseCases::List.method(:apply),
35
+ new: Idonethis::UseCases::New.method(:apply),
36
+ config: Idonethis::UseCases::Config.method(:apply),
37
+ git: ->(_, args) { Idonethis::UseCases::Git.apply(_, args.merge(git: adapters[:git], view: ->(msg) { puts msg }, fs: adapters[:fs]))},
38
+ help: ->(credential, args) { puts "TODO: implement help" }
39
+ }
40
+
41
+ if command == :list && opts.include?("teams")
42
+ return ->(credential, args) {
43
+ Idonethis::UseCases::Teams.apply(credential, args.merge(view: views[:teans]))
44
+ }
45
+ end
46
+
47
+ use_case = use_cases[command]
48
+ end
49
+
50
+ def choose_log(args={})
51
+ args[:verbose] == true ? ->(msg){puts "[LOG] #{msg}"} : ->(_){}
52
+ end
53
+
54
+ def parse(argv={})
55
+ args = {}
56
+
57
+ require 'optparse'
58
+
59
+ OptionParser.new do |opts|
60
+ opts.banner = "Usage: command [options]"
61
+
62
+ opts.on("-v", "--verbose", "Run verbosely") do |v|
63
+ args[:verbose] = v
64
+ end
65
+
66
+ opts.on("-m MESSAGE", "Message") do |m|
67
+ args[:message] = m
68
+ end
69
+
70
+ opts.on("-d", "Dry run") do |_|
71
+ args[:dry_run] = true
72
+ end
73
+
74
+ opts.on("-t TEAM", "--team TEAM" "Run against this team") do |team_name|
75
+ args[:team] = team_name
76
+ end
77
+
78
+ opts.on("-s WHEN", "--since WHEN" "Show git commits since when") do |value|
79
+ args[:since] = value
80
+ end
81
+ end.parse!
82
+
83
+ args
84
+ end
85
+ end
86
+ end
87
+ end
@@ -30,7 +30,7 @@ module Idonethis::UseCases
30
30
 
31
31
  def summarise(git, view, since, *dirs)
32
32
  dirs.map do |dir|
33
- commits = git.commits(dir, since).map{|it| %Q{[#{date_from(it)}] #{it.message}}}
33
+ commits = git.commits(dir, since).map{|it| %Q{[#{date_from(it)}] (#{it.author.name}) #{it.message}}}
34
34
  %Q{#{Pathname.new(dir).basename} (#{commits.size}):\n\n-- #{commits.join("\n-- ")}}
35
35
  end.join "\n\n"
36
36
  end
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.13.3
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Biddington
@@ -108,6 +108,7 @@ files:
108
108
  - lib/idonethis/cli/version.rb
109
109
  - lib/idonethis/index.rb
110
110
  - lib/idonethis/settings_file.rb
111
+ - lib/idonethis/use_cases/cli.rb
111
112
  - lib/idonethis/use_cases/config.rb
112
113
  - lib/idonethis/use_cases/git.rb
113
114
  - lib/idonethis/use_cases/list.rb