code_lister 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab05b837c5a1c82a86f45b2a732e1c94b5aa9f4c
4
- data.tar.gz: 7c511a1e1297223d9f96671045be7da41449e8d9
3
+ metadata.gz: dd7f9ad0380a230d4dccd591b283d0fed360832b
4
+ data.tar.gz: b4165437330aff861d9af903ec77e15d4e1ad3dc
5
5
  SHA512:
6
- metadata.gz: c58b793ebff0bd9e64f588983f4950c2f83b8ebfae3d2b3b5df0303c199be31d2409682b5198389db3c70416a6904d3f860ff892261039e5cca13545967f95a4
7
- data.tar.gz: c55a500f6437006295cb9dc1322a799d0420395ef6d761a970cc94a2cbba6533005c9ed763838da93c9478bcef2f2c88d9580d17acdb2c220b909d13614e527e
6
+ metadata.gz: bf2527f11af7c5b6d9f2363c2a52f859db786a2c74776db90f561bb0b680ee1596623056a6f72de5d65e597b418c4942bb919a266117f9293f04ef042b733c58
7
+ data.tar.gz: bae0153c61986aa011960c60552a60b91e2a75d9edad2f2f12bc3b8e3a9f767c164dcdb260b66c86e0bd73c4ab29b4e9f698963e49a0e88da8613f315bc2e67f
data/README.md CHANGED
@@ -154,6 +154,10 @@ always welcome.
154
154
 
155
155
  ### Changelogs
156
156
 
157
+ #### 0.0.5
158
+
159
+ - Refactoring the CLI options to make it easy for re-use in other library.
160
+
157
161
  #### 0.0.4
158
162
 
159
163
  - Add `ignore-case` option
@@ -2,57 +2,62 @@ require 'thor'
2
2
  require_relative 'core_ext/hash'
3
3
 
4
4
  module CodeLister
5
- class CLI < Thor
5
+ class BaseCLI < Thor
6
+ def self.shared_options
7
+ method_option :base_dir,
8
+ aliases: "-b",
9
+ desc: "Base directory",
10
+ default: Dir.pwd
6
11
 
7
- desc "find", "List files by extensions, patterns, and simple criteria"
12
+ method_option :exts,
13
+ aliases: "-e",
14
+ desc: "List of extensions to search for",
15
+ type: :array,
16
+ default: []
8
17
 
9
- method_option :base_dir,
10
- aliases: "-b",
11
- desc: "Base directory",
12
- default: Dir.pwd
18
+ method_option :inc_words,
19
+ aliases: "-n",
20
+ desc: "List of words to be included in the result if any",
21
+ type: :array,
22
+ default: []
13
23
 
14
- method_option :exts,
15
- aliases: "-e",
16
- desc: "List of extensions to search for",
17
- type: :array,
18
- default: []
24
+ method_option :exc_words,
25
+ aliases: "-x",
26
+ desc: "List of words to be excluded from the result if any",
27
+ type: :array,
28
+ default: []
19
29
 
20
- method_option :inc_words,
21
- aliases: "-n",
22
- desc: "List of words to be included in the result if any",
23
- type: :array,
24
- default: []
30
+ method_option :ignore_case,
31
+ aliases: "-i",
32
+ desc: "Match case insensitively",
33
+ type: :boolean,
34
+ default: true
25
35
 
26
- method_option :exc_words,
27
- aliases: "-x",
28
- desc: "List of words to be excluded from the result if any",
29
- type: :array,
30
- default: []
36
+ method_option :recursive,
37
+ aliases: "-r",
38
+ desc: "Search for files recursively",
39
+ type: :boolean,
40
+ default: true
31
41
 
32
- method_option :ignore_case,
33
- aliases: "-i",
34
- desc: "Match case insensitively",
35
- type: :boolean,
36
- default: true
42
+ method_option :version,
43
+ aliases: "-v",
44
+ desc: "Display version information",
45
+ type: :boolean,
46
+ default: false
47
+ end
48
+ end
49
+ end
37
50
 
38
- method_option :recursive,
39
- aliases: "-r",
40
- desc: "Search for files recursively",
41
- type: :boolean,
42
- default: true
51
+ module CodeLister
52
+ class CLI < CodeLister::BaseCLI
43
53
 
44
- method_option :version,
45
- aliases: "-v",
46
- desc: "Display version information",
47
- type: :boolean,
48
- default: false
54
+ desc "find", "List files by extensions, patterns, and simple criteria"
55
+ shared_options
49
56
  def find
50
-
51
57
  if options[:version]
52
58
  puts "You are using CodeLister Version #{CodeLister::VERSION}"
53
59
  exit
54
60
  end
55
-
56
61
  CodeLister::Main.run(options.symbolize_keys)
57
62
  end
58
63
 
@@ -4,10 +4,9 @@ module CodeLister
4
4
 
5
5
  def run(options = {})
6
6
  args = default_options.merge(options)
7
-
8
7
  files = CodeLister.files(args)
9
8
 
10
- ## Now filter out the list any?
9
+ # Now filter out the list if any
11
10
  inc_words = args.fetch(:inc_words, [])
12
11
  exc_words = args.fetch(:exc_words, [])
13
12
 
@@ -1,3 +1,3 @@
1
1
  module CodeLister
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_lister
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burin Choomnuan