File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 5
5
require 'optparse'
6
6
7
7
class Path
8
- def initialize ( *args )
9
- path_string = args . empty? ? ENV [ 'PATH' ] : args . join ( ":" )
8
+ def initialize ( var_name , *args )
9
+ path_string = args . empty? ? ENV [ var_name ] : args . join ( ":" )
10
10
@elements = path_string . split ( /:/ )
11
11
end
12
12
22
22
23
23
24
24
def parse_args
25
- options = { }
25
+ options = {
26
+ var_name : 'PATH'
27
+ }
26
28
27
29
op = OptionParser . new do |opts |
28
30
opts . banner = <<-EOS . gsub ( /^ */ , '' )
@@ -37,11 +39,14 @@ def parse_args
37
39
$PATH.
38
40
EOS
39
41
40
- options [ :clean ] = false
41
42
opts . on ( "-c" , "--clean" , "Clean path, removing any dupes." ) do
42
43
options [ :clean ] = true
43
44
end
44
45
46
+ opts . on ( "-m" , "--manpath" , "Examine MANPATH rather than PATH." ) do
47
+ options [ :var_name ] = 'MANPATH'
48
+ end
49
+
45
50
opts . on ( "-p" , "--pack" , "Pack path into one long line." ) do
46
51
options [ :pack ] = true
47
52
end
@@ -58,6 +63,6 @@ args, options = parse_args
58
63
59
64
separator = options [ :pack ] ? ":" : "\n "
60
65
61
- path = Path . new ( *args )
66
+ path = Path . new ( options [ :var_name ] , *args )
62
67
path . clean if options [ :clean ]
63
68
path . show ( separator )
You can’t perform that action at this time.
0 commit comments