check_names 0.4.0 → 0.5.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
  SHA256:
3
- metadata.gz: 8e8b673b887e26b3ec7100c88369de69d82f985a65389b9bbf4d901e0dc76a53
4
- data.tar.gz: c5c5d6f4157348de247b653598360cc6da83d56940fa85a0e4a0367b6b13a2c7
3
+ metadata.gz: 6bab692e352dc013e789d94d727cdc70520b1bf58a6ec2547dc770f94956e086
4
+ data.tar.gz: 8f753e604b1ceca688e5205ef9b4c55e17bbead39f3b2c3484038ae38fcd9b30
5
5
  SHA512:
6
- metadata.gz: ed35fb48743e2651df7d8d03fccc9394ef69d69ce5268059d11542a84ec941759c03092120b1cedea4c339b4b1426446d5e857a74bcab46a5e8111fb3468f40d
7
- data.tar.gz: db674a40f05f65f22705ed8eca975c6452a02bc2322102fe889990e7313d8cbb1d6974f8cba57498ebf875d20a89e0c9c43d99e3180c84aacf3f42989d7f079d
6
+ metadata.gz: f6eba30abc087cbf322224c1d689df2b3ed234252b3ac7e239b66046f20c45c62d9736961c6ba257ab054e49fc74c6c1ac7581de3aef23075ba8bc6bd2f89d5d
7
+ data.tar.gz: 51318e1543af9c775d589a6b5bdb401eb8383a3e74b8a4413a6d2ba073fe093403de878adde1627ce86e4ac415024279573bfb625f888d9ce2e36fdc2bf2869f
data/exe/check_names CHANGED
@@ -11,16 +11,19 @@
11
11
  # 4. Does an alias with this name already exist?
12
12
  # 5. Does a function with this name already exist?
13
13
 
14
+ require 'optimist'
14
15
  require_relative '../lib/check_names/version'
15
16
  require_relative '../lib/check_names'
16
17
 
17
- def show_help
18
- puts <<-HELP
19
- check_names: Check whether a proposed gem name already exists
20
- Version #{CheckNames.version}
18
+ BANNER = <<-BANNER_TEXT
19
+ #{File.basename(__FILE__)}:
20
+ ersion #{CheckNames.version}
21
+
22
+ Check whether a proposed gem name already exists
21
23
 
22
24
  Usage:
23
- check_names [OPTIONS]... [names]...
25
+ #{File.basename(__FILE__)} OPTIONS NAME...
26
+
24
27
 
25
28
  check_names looks to see whether the names provided are already in use.
26
29
  It outputs the usage (if any) of each name on $STDOUT. It exits with a
@@ -36,26 +39,28 @@ check_names checks for each of the following uses:
36
39
  - The name of a shell function
37
40
  - The name of an executable (reachable via \$PATH)
38
41
 
39
- The following options are available:
42
+ The following options are allowed:
43
+ BANNER_TEXT
40
44
 
41
- --help -h Print this help information
42
- --all -a Report all uses of the name. (Otherwise, check_names stops at
43
- the first use it finds.)
44
- HELP
45
- end
45
+ def main
46
+ opts = Optimist.options do
47
+ version CheckNames.version
48
+ banner BANNER
49
+ opt :all, "Check for all possible uses. (Default is to stop at the first one found.)", default: false
50
+ educate_on_error
51
+ end
46
52
 
47
- def main(args)
53
+ all = opts[:all]
54
+ args = ARGV
48
55
  args = args.map { |arg| arg.downcase }
49
- all = args.index { |arg| %w{-a --all}.include?(arg) }
50
- args.delete_at(all) if all
51
- if args.size == 0 || %w{-h --help help}.include?(args.first)
52
- show_help
56
+
57
+ if args.size == 0
58
+ Optimist.educate
53
59
  exit
54
60
  end
55
61
 
56
62
  rc = 0
57
63
  args.each.with_index(0) do |arg, i|
58
- results = []
59
64
  print "#{arg}: "
60
65
  checks_printed_count = 0
61
66
  (1...(CheckNames.check_methods.size)).each do |check|
@@ -77,5 +82,5 @@ def main(args)
77
82
  end
78
83
 
79
84
  if __FILE__ == $0
80
- main(ARGV)
85
+ main
81
86
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CheckNames
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
 
6
6
  def self.version
7
7
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_names
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard LeBer